F
Filament14mo ago
Wannes

SelectFilter with null

I also need a check of null on my SelectFilter (its a nullable property)
SelectFilter::make('assigned_to')
->multiple()
->options(function () {
$users = \App\Models\User::all();
$options = $users->pluck('name', 'id')->toArray();
$options = array_merge([null => 'Unassigned'], $options);
return $options;
}),
SelectFilter::make('assigned_to')
->multiple()
->options(function () {
$users = \App\Models\User::all();
$options = $users->pluck('name', 'id')->toArray();
$options = array_merge([null => 'Unassigned'], $options);
return $options;
}),
So I want to select on unassigned, and that's when the value is null. How can I do this? The code above doesn't work. Thx!
1 Reply
toeknee
toeknee14mo ago
So you want a filter to show where value is null? In which case add a null boolean filter? Or write your own query with https://filamentphp.com/docs/2.x/tables/filters
Want results from more Discord servers?
Add your server