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 Harrin2y ago
does the if statement work properly for 0 try if (filled($data['value']))
rajul
rajulOP2y ago
Thanks Dan, filled is working for both 0 and 1. basically empty function return true for 0.
Want results from more Discord servers?
Add your server