diff --git a/src/Collection.php b/src/Collection.php index 2dd26df..77585b9 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -30,7 +30,7 @@ public function linkNodes() /** @var Model|NodeTrait $child */ foreach ($children as $child) { - $child->setRelation('parent', $node); + $child->setRelation('parent', clone $node); } $node->setRelation('children', BaseCollection::make($children)); diff --git a/src/NodeTrait.php b/src/NodeTrait.php index 167c001..76aca9e 100644 --- a/src/NodeTrait.php +++ b/src/NodeTrait.php @@ -1078,19 +1078,6 @@ public function hasMoved() return $this->moved; } - /** - * @return array - */ - protected function getArrayableRelations() - { - $result = parent::getArrayableRelations(); - - // To fix #17 when converting tree to json falling to infinite recursion. - unset($result['parent']); - - return $result; - } - /** * Get whether user is intended to delete the model from database entirely. *