【发布时间】:2018-06-20 21:07:55
【问题描述】:
我对模型集合 (Eloquent) 有疑问。
我有两个模型 ActivationDetail 的集合,我需要将它们合并到一个集合中,集合具有相同的结构,所以合并它们不会很困难吧?
好吧,在互联网和 API 本身中搜索我发现了 merge() 方法,它允许我将两个集合合二为一。喜欢找到here、here、and here。
但是,此方法返回我一行。 (sizeof($detail) 正在返回 1)虽然格式正确,但我不知道我在这里缺少什么。
我做错了什么?
//first collection
$detail = ActivationDetail::[redacted]->get();
// second collection, the query is of the same structure
// as the previous one, but it's edited to allow the selection
// of null fields (which can't be possible in the previous
// due how Inner Joins work)
$detailB = ActivationDetail::[redacted]->get();
$detail = $detail->merge($detailB);
//this returns "1"
dd(sizeof($detail));
【问题讨论】:
-
请显示
dd($detail, $detailB)的结果
标签: php laravel eloquent laravel-collection