How to make table searchable?
I'm in the admin panel, trying to apply a custom search to the table, but im unable to show the search input :/
this is what im trying:
14 Replies
im trying to follow this tuto - https://v2.filamentphp.com/tricks/customize-table-search
Filament
Customize table search by Z3d0X - Tricks - Filament
Filament is a collection of tools for rapidly building beautiful TALL stack apps, designed for humans.
i know is v2, and im using v3, but should be similar, idk how
Have you made any columns searchable?
no
is mandatory?
i made a column searchable, now it appears. but there is no way to make the search appear without making a col searchable?
Nope, you should just be able to do ->searchable() on the table itself?
Or instead of isTableSearchable you can override isSearchable
the thing is that i wanna search a json column containing an array of items :/
Guessing it's a custom form type system where you have a json column with the response values?
yes
this is what im trying now:
if the column is a json object, works - i have it done in another project
but if the column is an array of objects, it doesnt hmmmm
Ahh I see, on mine I generated the columns based on the forms schema then implemented a custom searchable query for each. So have you managed to get the search box to pop up now just the query isn't working?
yeah sorry, i managed it to pop up, this should be a diferent question 🙌
and this seems that does the trick -
$query->where('responses', 'like', "%{$search}%");
i guess as json col is a string, it just searches though it
i thought didnt work but i guess had to reload or something, now works
oh wait a second wtfYeah, that should be fine unless you're wanting to search a specific column, think you can treat it like an object in whereJsonContains if you wanted to search specific columns
now doesnt work
let me clear cahce or something
ah, is the case
i was searching "et et", and one of my rows has "Et et", so nothing was appearing
if i search it like this: "Et et", i see it
hmm okay now im going to search how to make case insensitive
Just strtoupper/lower both the column contents and your search term
yeah cool
final method:
thanks for the help (: