如何结合两个雄辩的Laravel

时间:2016-08-01 05:21:59

标签: php laravel laravel-4 eloquent

我有两个雄辩,这是每个没有union的代码。 所以我希望根据来自stylesorganizations

的已登录用户获取所有schools
$organization_styles    = Auth::user()->teacher->school->organization->styles;
$school_styles          = Auth::user()->teacher->school->styles;

echo "<pre>";
print_r($organization_styles->toArray());
echo "</pre>";

echo "------------------------";

echo "<pre>";
print_r($school_styles->toArray());
echo "</pre>";

这就是结果。

enter image description here

我想结合它,这是我目前的测试,但它给了我错误

$test = $school_styles->union($organization_styles);

1 个答案:

答案 0 :(得分:0)

集合类没有 union()方法。您需要使用 merge()方法。它应该完全符合您的需要 - 它将合并两个集合并确保样式不会重复:

$styles = $school_styles->merge($organization_styles);
相关问题