Skip to content

Commit f98feb3

Browse files
Bart Hijmanssdebacker
Bart Hijmans
authored andcommitted
Made a protected variable for $parentRelation
1 parent 1714347 commit f98feb3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/NestableCollection.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class NestableCollection extends Collection
2626

2727
protected $childrenName = 'items';
2828

29+
protected $parentRelation = 'parent';
30+
2931
public function __construct($items = [])
3032
{
3133
parent::__construct($items);
@@ -219,9 +221,9 @@ protected function setParentsRecursive(&$items, &$parent = null)
219221
{
220222
foreach ($items as $item) {
221223
if ($parent) {
222-
$item->setRelation('parent', $parent);
224+
$item->setRelation($this->parentRelation, $parent);
223225
}
224-
$this->setParentsRecursive($item->items, $item);
226+
$this->setParentsRecursive($item->{$this->childrenName}, $item);
225227
}
226228
}
227229
}

0 commit comments

Comments
 (0)