diff --git a/src/SelectTree.php b/src/SelectTree.php index ac4963f..1845b7e 100644 --- a/src/SelectTree.php +++ b/src/SelectTree.php @@ -251,7 +251,7 @@ private function buildTreeFromResults($results, $parent = null): Collection // If the tree has strict rull parent root nodes, only retrieve children whose parent is the null value // Otherwise, promote other orphaned children to root nodes $orphanedResults = $this->hasStrictNullParentRootNodes() - ? [$parent => $resultCache[$parent]['children']] + ? [$parent => $resultCache[$parent]['children'] ?? []] : array_map( fn ($item) => $item['children'], array_filter(