public function children() { return $this->hasMany(get_class($this), 'parent_id' ); } public function allChildren() { return $this->children()->with( 'allChildren' ); }
取自:
https://learnku.com/articles/12466/unlimited-classification