public function path() { $path = [Folder::find($this->id)]; $folder_id = $this->parent; while ($folder_id) { $folder = Folder::find($folder_id); array_push($path, $folder); $folder_id = $folder->parent; } return array_reverse($path); }