How can i search a related model name in TextColumn?
i cannot search for a post name.
Solution:Jump to solution
Something like this
```php
TextColumn::make('user.name')
->label(__('By'))
->searchable(...
8 Replies
Solution
Something like this
I don't think you need to override the query? You could could just do ...
NOTE that it's posts.name in the searchable(), ie. the table name, not the relation name.
Very nice! Much simpler, but a bit unintuitive in the context of the form builder.
My question isn't directly related, but this is the closest relevant question I could find here. I use a custom union of two tables in my relation manager
getTableQuery()
to return the proper set of data. When I try to search, all the results from the set that is union-ed to the first set is shown. I have used Telescope to dig into the queries, and the filtering is only being done to the first part of the query
When I realized this, I tried using a custom query
I believe this is a MYSQL limitation, not a Filament bug
my custom query adds the appropriate where clauses
and when I actually use get()
and log the result, the data is correctly filtered
however, I cannot get searchable()
to use that correctly filtered data
any ideas about what is going on here?Do you have a help thread that details your custom RM query?
I don't
But I have verified that it is pulling the correct data
What's strange is that it doesn't appear to be filtering anything at all
Should I start a separate thread?
Yes please. So we don't spam OP with your stuff.