belongsTo(static::class); } public function children(): HasMany { return $this->hasMany(static::class, $this->parentColumn); } /* * same level items */ public function allChildren() { return $this->children()->with('allChildren'); } /* * not working!! */ public function root() { return $this->parent ? $this->parent->root() : $this; } }