Skip to content

Conversation

@stefket
Copy link
Contributor

@stefket stefket commented Nov 7, 2025

In version 4.0.8, the following error occurs:

CodeWithDennis\FilamentSelectTree\SelectTree::getResults(): Return value must be of type Illuminate\Support\Collection|array|null, Illuminate\Support\LazyCollection returned

This commit updates the return type to ensure compatibility.

@CodeWithDennis
Copy link
Owner

Shouldn't it support both?

@CodeWithDennis
Copy link
Owner

@stefket

@stefket
Copy link
Contributor Author

stefket commented Jan 19, 2026

@CodeWithDennis

Sorry Dennis for not getting back to you sooner.

It’s been a while, and I honestly can’t remember exactly when the issue occurs.

I’ll take another look right away and get back to you as soon as I have more details.

@stefket
Copy link
Contributor Author

stefket commented Jan 19, 2026

I have found the place in my project, where the error occurs with version 4.0.8:

SelectTree::make('nav_item_id')
    ->query(fn () => NavItem::query(), 'text', 'parent_id')
    ->enableBranchNode()
    ->defaultOpenLevel(4)
    ->storeResults()
    ->disabledOptions(function (SelectTree $component): array {
        return $component
            ->getResults()
            ->filter(fn ($item) => filled($item->content_id))
            ->pluck('id')
            ->toArray();
    })

Accessing getResults inside the disabledOptions callback causes the error in my project.

But I agree with you — it would make more sense to allow both a LazyCollection and a regular Collection as the return type here. I’ve just corrected that.

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

@CodeWithDennis

Sorry Dennis for not getting back to you sooner.

It’s been a while, and I honestly can’t remember exactly when the issue occurs.

I’ll take another look right away and get back to you as soon as I have more details.

No worries and thanks!

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