class Nested extends Model{
public function nestedfunc()
{
return $this->hasMany(Nested::class, 'parent_id');
}
public function childnestedfunc()
{
return $this->hasMany(Nested::class, 'parent_id')->with('nestedfunc');
}
}
字符串
//这是我的递归模型函数。如何将分页添加到嵌套注解的根。我将所有注解存储到同一个表中
1.根注解1 -根1的嵌套注解....
1.根注解2 -根2的嵌套注解....
1.给根注解标页码
1.根注解3 -根3的嵌套注解....
- root comments 4 -nested commets of root 4.
1.给根注解标页码
1.等
1条答案
按热度按时间cx6n0qe31#
这里不需要两个独立的函数,关系可以递归地调用自己,所以首先将关系更改为
字符串
那么对于你的查询,你可以只做
型
在构建嵌套注解模型时,我还添加了一个作用域,使其更具可读性
型
所以现在我的控制器里的调用
型