F
Filamentβ€’4mo ago
binaryfire

Using eager loaded relationships in custom table column views

Hi all I have a custom table column that needs to use relationship data. I can access data using $getRecord()->user()->name . The problem is this isn't eager loaded so I get an extra query for every table row. Any ideas how I can solve that? Cheers
Solution:
I mean you add the dot with the relation I think all the record will be available! havent tested that case actually you can always override the query and add with()...
Jump to solution
4 Replies
Lara Zeus
Lara Zeusβ€’4mo ago
I think filament will eager load the relation if founded in the ::make('user.name')
binaryfire
binaryfireβ€’4mo ago
That's the way I normally do it. The problem is I need to access multiple attributes of the relationship in this view.
Solution
Lara Zeus
Lara Zeusβ€’4mo ago
I mean you add the dot with the relation I think all the record will be available! havent tested that case actually you can always override the query and add with()
binaryfire
binaryfireβ€’4mo ago
You were right, using dot notation to set any relationship attribute makes the whole relationship available in the view! Thanks πŸ™‚