Skip to content

Commit

Permalink
Made a protected variable for $parentRelation
Browse files Browse the repository at this point in the history
  • Loading branch information
Bart Hijmans authored and sdebacker committed Sep 30, 2020
1 parent 1714347 commit f98feb3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/NestableCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class NestableCollection extends Collection

protected $childrenName = 'items';

protected $parentRelation = 'parent';

public function __construct($items = [])
{
parent::__construct($items);
Expand Down Expand Up @@ -219,9 +221,9 @@ protected function setParentsRecursive(&$items, &$parent = null)
{
foreach ($items as $item) {
if ($parent) {
$item->setRelation('parent', $parent);
$item->setRelation($this->parentRelation, $parent);
}
$this->setParentsRecursive($item->items, $item);
$this->setParentsRecursive($item->{$this->childrenName}, $item);
}
}
}

0 comments on commit f98feb3

Please sign in to comment.