在我的标题中,我需要使用一些关系。我在AppServiceProvider中定义了变量。就像这样:
$v_categories = Category::where('parent_id', $v_group->id)->orderBy('order', 'asc')->get();
$view->with('categories', $v_categories);
在刀刃上,当我用前臂“分类”时,它的工作方式就像是一种魅力。
但当我试图将它与关系结合使用时,它抛出了一个异常。
Exception
Property [children] does not exist on this collection instance.
这是我的关系:
public function children()
{
return $this->hasMany('App\Category', 'parent_id');
}
我的问题是如何在刀片服务器中使用children函数和“categories”口才(来自AppServiceProvider)?
有个问题。但我不明白为什么?任何帮助都会很好。事先谢谢。