Skip to content

Commit 4aa41d2

Browse files
committed
Set parent relation on children when converting to tree
1 parent 484a6d0 commit 4aa41d2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Kalnoy/Nestedset/Collection.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public function toTree($rootNodeId = null)
5555
{
5656
$children = $dictionary->get($item->getKey(), []);
5757

58+
foreach ($children as $child)
59+
{
60+
$child->setRelation('parent', $item);
61+
}
62+
5863
$item->setRelation('children', new BaseCollection($children));
5964
}
6065

0 commit comments

Comments
 (0)