© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
3 replies
Jon Mason

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;
 
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}%");
    })
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to modify global search
FilamentFFilament / ❓┊help
2y ago
Modify global search query
FilamentFFilament / ❓┊help
3mo ago
How to modify the results text from global search?
FilamentFFilament / ❓┊help
3y ago
Modify query in Resource if not searching
FilamentFFilament / ❓┊help
2y ago