F
Filament15mo ago
morty

What is the difference between these two options on a select filter?

I've seen this done both ways but unsure which to use?
SelectFilter::make('tags')
->options(
fn (): array => Tag::getWithType('crm.accounts')->pluck('name', 'name')->all()
)
SelectFilter::make('tags')
->options(
fn (): array => Tag::getWithType('crm.accounts')->pluck('name', 'name')->all()
)
vs
SelectFilter::make('tags')
->options(Tag::getWithType('crm.accounts')->pluck('name', 'name'))
SelectFilter::make('tags')
->options(Tag::getWithType('crm.accounts')->pluck('name', 'name'))
Solution:
🤷‍♂️ nothing you dont need ->all() at all all if you have some operations on the collection like filtering or additions etc...
Jump to solution
4 Replies
Solution
Lara Zeus
Lara Zeus15mo ago
🤷‍♂️ nothing you dont need ->all() at all all if you have some operations on the collection like filtering or additions etc
morty
mortyOP15mo ago
What about the closure vs no closure? Same thing?
Lara Zeus
Lara Zeus15mo ago
if you need to inject some dependencies use closure
morty
mortyOP15mo ago
Gotcha, thanks.

Did you find this page helpful?