How to use Laravel Scout in Global Search?
https://filamentphp.com/docs/3.x/tables/advanced#searching-records-with-laravel-scout
https://filamentphp.com/docs/4.x/tables/overview#searching-records-with-laravel-scout
So lets say i have a songs resource.
in the list songs i have:
then, in the table search input, i make a search with a typo. it works.
but then, in the global search, it just doesnt work.
yeah, in the song resource i added ->searchable and also in the model i defined the toSearchableArray properly
is possible to integrate laravel scout in global search without plugins?
4 Replies
i say without plugins cuz im trying to update from v3 to v4 but i cant because of this. because of this, i mean, because i was using a plugin to be able to search in globally using laravel scout but this plugin isnt available for v4
that is why im trying to find a solution without any plugins
and then, i will be able to update i would guess
possible solution for v4, if someone thinks this can/should be improved, please let me know how:
inside
app/Filament/Resources/Songs/SongResource.php
Looks good. I think another option would be to register a custom
GlobalSearchProvider
.how would u do that?
You can bind a custom provider via
app->bind(GlobalSearchProvider::class, YourProvider::class)
. Search for the DefaultGlobalSearchProvider
as an example. You could check whether that model is using Scout and apply your logic.
Just a thought. I haven't done that before, but might be cleaner than adding it to every resource