Modify the search value prior to searching?

I store money as integers in my database. I want the user to be able to search dollar amounts, but if the user searches 54.60, it's not finding anything because it would need to be 5460. How can I modify the search variable before the search is performed?
Solution:
You may customize how the search is applied to the Eloquent query using a callback: ``` use Filament\Tables\Columns\TextColumn; use Illuminate\Database\Eloquent\Builder; ...
Jump to solution
1 Reply
Solution
Patrick
Patrick12mo ago
You may customize how the search is applied to the Eloquent query using a callback:
use Filament\Tables\Columns\TextColumn;
use Illuminate\Database\Eloquent\Builder;

TextColumn::make('full_name')
->searchable(query: function (Builder $query, string $search): Builder {
return $query
->where('first_name', 'like', "%{$search}%")
->orWhere('last_name', 'like', "%{$search}%");
})
use Filament\Tables\Columns\TextColumn;
use Illuminate\Database\Eloquent\Builder;

TextColumn::make('full_name')
->searchable(query: function (Builder $query, string $search): Builder {
return $query
->where('first_name', 'like', "%{$search}%")
->orWhere('last_name', 'like', "%{$search}%");
})
Want results from more Discord servers?
Add your server