diff --git a/src/Collection/CollectionTrait.php b/src/Collection/CollectionTrait.php index 5499f411f54..5a5bb642588 100644 --- a/src/Collection/CollectionTrait.php +++ b/src/Collection/CollectionTrait.php @@ -390,9 +390,11 @@ public function nest($idPath, $parentPath) return; } + $children = []; foreach ($values as $id) { - $parents[$key]['children'][] =& $parents[$id]; + $children[] =& $parents[$id]; } + $parents[$key]['children'] = $children; }; $collection = new MapReduce($this, $mapper, $reducer);