File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 55use Illuminate \Database \Eloquent \Model as Eloquent ;
66use Franzose \ClosureTable \Contracts \EntityInterface ;
77use Franzose \ClosureTable \Extensions \Collection ;
8+ use Illuminate \Database \Eloquent \Relations \BelongsTo ;
89use Illuminate \Database \Eloquent \Relations \HasMany ;
910use Illuminate \Support \Arr ;
1011use InvalidArgumentException ;
@@ -354,6 +355,16 @@ public function getParent(array $columns = ['*'])
354355 return $ this ->exists ? $ this ->find ($ this ->parent_id , $ columns ) : null ;
355356 }
356357
358+ /**
359+ * Returns many-to-one relationship to the direct ancestor.
360+ *
361+ * @return BelongsTo
362+ */
363+ public function parent ()
364+ {
365+ return $ this ->belongsTo (get_class ($ this ), $ this ->getParentIdColumn ());
366+ }
367+
357368 /**
358369 * Returns query builder for ancestors.
359370 *
You can’t perform that action at this time.
0 commit comments