讨论数量:
@pndx 控制器 获取无限分类 user::query()->with('allChildren')->get(); 下面的方法是定义在user模型中 // 模型文件 public function children() { return $this->hasMany(get_class($this), 'parent_id' ,'id'); } public function allChildren() { return $this->children()->with( 'allChildren' ); }
推荐文章: