Skip to content

feat: toggle strict null parent root nodes#215

Merged
CodeWithDennis merged 3 commits into
CodeWithDennis:4.xfrom
gp-lnuff:4.x
May 27, 2026
Merged

feat: toggle strict null parent root nodes#215
CodeWithDennis merged 3 commits into
CodeWithDennis:4.xfrom
gp-lnuff:4.x

Conversation

@gp-lnuff

Copy link
Copy Markdown
Contributor

As per #212, here is a draft of my suggestion.
By using the strictNullParentRootNodes() configuration method, the buildTree() method will not turn orphaned child nodes into root nodes. An hasStrictNullParentRootNodes() helper has been added to this end.
Needs documentation update.
Consider calling the configuration method by default in relationship() on a major version change.

@gp-lnuff gp-lnuff marked this pull request as draft May 22, 2026 16:07
@gp-lnuff gp-lnuff marked this pull request as ready for review May 25, 2026 11:08
@CodeWithDennis

Copy link
Copy Markdown
Owner

Thanks for the work on this! I think its a good solution for this version and like you said maybe in a major version we can set it as default?

@gp-lnuff

Copy link
Copy Markdown
Contributor Author

Indeed, it would be as simple as adding the helper method call to the relationship() method - if we only have to set $strictNullParentRootNodes to true, we can just do that directly, but with the helper method we could even use a Closure to have more fine-grained control of the behaviour depending on the relationship() method call, such as relationship type, or whether the queries have been modified.

@CodeWithDennis CodeWithDennis merged commit 63472b9 into CodeWithDennis:4.x May 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants