我有两个雄辩,这是每个没有union
的代码。
所以我希望根据来自styles
和organizations
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>";
这就是结果。
我想结合它,这是我目前的测试,但它给了我错误
$test = $school_styles->union($organization_styles);
答案 0 :(得分:0)
集合类没有 union()方法。您需要使用 merge()方法。它应该完全符合您的需要 - 它将合并两个集合并确保样式不会重复:
$styles = $school_styles->merge($organization_styles);