Global Search Hooks
Hi all,
Is there a way to "hook" searches? I want to transform some of the data before it hits the models for searching.
As in, the user will be able to write their own query (e.g. `post:"example-post" AND hits:1337)). I'm going to transform that back to SQL using an API call.
So I guess the question here is, is there a way to "intercept" searches?
4 Replies
See the second paragraph here, you can override the global search query. https://filamentphp.com/docs/3.x/panels/resources/global-search#adding-extra-details-to-global-search-results
Thank you @awcodes, how can I access the actual search content here though? (i.e. the content input to the search box) - as I’ll need to transform it to a query
My recommendation would be to do some source diving and understanding how it all works. Unfortunately there’s not going to be an easy answer for your use case. I was just trying to point out that over ridding the query is possible with that method.
Thanks again!
Looking at the source code, it looks like this method can accept
$search
which may be what I'm looking for - https://github.com/filamentphp/filament/blob/3.x/packages/panels/src/Resources/Resource.php#L448GitHub
filament/packages/panels/src/Resources/Resource.php at 3.x · filame...
A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS. - filamentphp/filament