F
Filamentβ€’8mo ago
Taz416

Multiple search terms

Hi - Is there a way to 'OR' the search terms for a single column ie A2 or A3 value in a field?
8 Replies
adnn
adnnβ€’8mo ago
You can create a filter that has a disjunction OR option. For example https://demo.filamentphp.com/shop/products/products you have the code on github
LeandroFerreira
LeandroFerreiraβ€’8mo ago
this? https://filamentphp.com/docs/3.x/tables/columns/getting-started#searching
TextColumn::make('full_name')
->searchable(query: function (Builder $query, string $search): Builder {
return $query
->where('first_name', 'like', "%{$search}%")
->orWhere('last_name', 'like', "%{$search}%");
})
TextColumn::make('full_name')
->searchable(query: function (Builder $query, string $search): Builder {
return $query
->where('first_name', 'like', "%{$search}%")
->orWhere('last_name', 'like', "%{$search}%");
})
Taz416
Taz416OPβ€’8mo ago
@adnn I don't see a Product Resource in the github repo that matches the demo. @Leandro Ferreira Not really - I want to put more than one search term into the search box and have it perform an 'OR' on a single column ie If the name field contains 'Bill' OR 'John'. I guess I can write my own filter and get the terms inside of an input field in the filter form ...
LeandroFerreira
LeandroFerreiraβ€’8mo ago
hum.. a custom filter I guess
adnn
adnnβ€’8mo ago
Everything on that site is in the github demo repo, including a working OR filter
Taz416
Taz416OPβ€’8mo ago
@adnn could you paste a link to the repo? The one I am looking at does not have a ProductResource. This is the repo linked from the demo site.
No description
Taz416
Taz416OPβ€’8mo ago
@Leandro Ferreira Thanks I will look at that. πŸ˜‰
Want results from more Discord servers?
Add your server