Filter by multiple Relationship attributes

On a select is it possible to filter by multiple attributes?
4 Replies
Dan Harrin
Dan Harrin2y ago
wdym by filter show me what you mean
CarbonNanotubes
CarbonNanotubesOP2y ago
By filtering I mean when you type into a select find the option you are looking for. I read through the docs and didn't see anything that would work for this use case so I I thought for the time being. I can't show a screenshot of the exact select I'm working with since it has confidential employee information. Basically the selects options is a list of employees and I want to be able to type in their employee number, first name, last name, or full name to find them in the options. What I have done for now is since the options of employee information is just a database view, I added a column that concats the first name, last name and employee number together and set that as my property instead. Now one issue I run into with this is when I try to search the options for an employee number the search basically does not work. Only first and last name work
Select::make('employee')
->multiple()
->relationship('employee', 'SEARCHABLE')
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->NUMBER} - {$record->FIRST_NAME} {$record->LAST_NAME}")
->preload(),
Select::make('employee')
->multiple()
->relationship('employee', 'SEARCHABLE')
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->NUMBER} - {$record->FIRST_NAME} {$record->LAST_NAME}")
->preload(),
Dan Harrin
Dan Harrin2y ago
->searchable(['NUMBER', 'FIRST_NAME', 'LAST_NAME'])
CarbonNanotubes
CarbonNanotubesOP2y ago
How did I miss that in the docs!? When I was looking at this yesterday I was thinking "I'm surprised they didn't think of this use case when they have thought about so many other use cases"
Want results from more Discord servers?
Add your server