How implement a filter in a filament resource that uses the attribute of a HasOne relationship
Hello everyone. I have a question, how can I implement a filter in a filament resource that uses the attribute of a HasOne relationship. For example, I have two models Author and Profile, where Author hasOne Profile and Profile belongsTo Author. In profile there is the boolean attribute is_featured. What I want is to filter the list of authors by that attribute. I tried TernaryFilter::make('profile.is_featured') but it shows me all the authors.
1 Reply
https://filamentphp.com/docs/3.x/forms/fields/select#customizing-the-relationship-query You can customize the query like this