模型无限分类
// 模型文件
public function children() {
return $this->hasMany(get_class($this), 'parent_id' ,'id');
}
public function allChildren() {
return $this->children()->with( 'allChildren' );
}
// 模型文件
public function children() {
return $this->hasMany(get_class($this), 'parent_id' ,'id');
}
public function allChildren() {
return $this->children()->with( 'allChildren' );
}