Skip to content

Conversation

@nathanheffley
Copy link
Contributor

This PR adds getTreeUsing which registers a callback that developers can use to customize what the tree looks like instead of automatically mapping it to a relationship.

This allows users to pass in an array in the proper format such as:

[
    [
        'name' => 'Parent Name',
        'value' => 'parent_value',
        'children' => [
            [
                'name' => 'Child Name',
                'value' => 'child_value',
                'children' => [], // optional if no children
            ],
           // etc...
        ],
    ],
    // etc...
]

The resulting value is an array made of the values of all selected options.

@CodeWithDennis
Copy link
Owner

CodeWithDennis commented Jan 17, 2026

Perhaps we can also allow public function getTreeUsing(Closure|array $value): static instead of only a closure?

Could you also add some README? @nathanheffley

@nathanheffley
Copy link
Contributor Author

Could you also add some README?

Ah, I knew I was forgetting something! Yes, I can do both of those things 👍

@CodeWithDennis CodeWithDennis merged commit 47e5b27 into CodeWithDennis:4.x Jan 19, 2026
1 check passed
@CodeWithDennis
Copy link
Owner

Thank you for adding this feature!

@nathanheffley nathanheffley deleted the add-get-tree-using branch January 19, 2026 13:44
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