F
Filament15mo ago
roni

In select filer 0 is giving all results

For following SelectFilter, If I select 0 then all results are coming in table , whereas 1 is working fine. Schema for verified is : $table->boolean('verified')->nullable();
SelectFilter::make('verified')
->options([
0 => 'Unverified',
1 => 'Verified',
])
->query(function (Builder $query, array $data) {
if (!empty($data['value']))
$query->whereHas('metadata',
fn(Builder $query) => $query->where('verified', '=', $data['value']));
}),
SelectFilter::make('verified')
->options([
0 => 'Unverified',
1 => 'Verified',
])
->query(function (Builder $query, array $data) {
if (!empty($data['value']))
$query->whereHas('metadata',
fn(Builder $query) => $query->where('verified', '=', $data['value']));
}),
Please let me know if I am doing something wring here?
2 Replies
Dan Harrin
Dan Harrin15mo ago
does the if statement work properly for 0 try if (filled($data['value']))
roni
roni15mo ago
Thanks Dan, filled is working for both 0 and 1. basically empty function return true for 0.