Laravel Baum如何在getAncestorsAndSelf()方法中获取相关模型

时间:2017-09-18 13:42:41

标签: laravel-5 eloquent package relation

对嵌套集使用Laravels Baum包我尝试在getAncestorsAndSelf()上获取关系模型但不起作用

$tree = \App\GroupDeprecator::where('id', $this->team_id)->with('lead')->first();
      dd($tree); //this one shows the user object
      dd($tree->getAncestorsAndSelf());//this one does not shows the user object

在这种情况下出了什么问题?

1 个答案:

答案 0 :(得分:0)

你是如何解决的?代码看起来很好,应该可以工作,除非在数据库中手动更新,我会这样做:

GroupDeprecator::rebuild(true)

更新lft, rgt and depth