Relationship search in belongsTo select
Hello, is it possible to make a relationship search for a resource relationship?
I have this for example:
Forms\Components\Select::make('contact_id')
->relationship(name: 'contact', titleAttribute: 'email')
->searchable(['first_name', 'last_name', 'email', 'organisation.name'])
->required(),
This is not working because 'organisation.name' is not a valid column. Is it possible to do it or do I have to do it differently so I can search contacts by their organisation name?
Thank you!
3 Replies
Have you tried using the
getSearchResultsUsing()
method? Might be helpful.
https://filamentphp.com/docs/3.x/forms/fields/select#returning-custom-search-resultsOne other option might be to use the
modifyQueryUsing
parameter of the relationship()
method
Will give it a try thanks!