Skip to content

Commit a7c6223

Browse files
Merge pull request #25 from CodeWithDennis/23-nullvalue
Fixed an issue where tree would go into inf loop
2 parents eb9424b + c85ad1b commit a7c6223

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/SelectTree.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ protected function setUp(): void
8484
private function buildTree($parent = null): array|Collection
8585
{
8686
// Assign the parent's null value to the $parent variable if it's not null
87-
$parent = $this->getParentNullValue() ?? $parent;
87+
if ($parent == null || $parent == $this->getParentNullValue()) {
88+
$parent = $this->getParentNullValue() ?? $parent;
89+
}
8890

8991
// Create a default query to retrieve related items.
9092
$defaultQuery = $this->getRelationship()

0 commit comments

Comments
 (0)