F
Filament14mo ago
Emaz

query override

ChatGPT just told me to override Filament's query method (see photo) This is because I would have to traverse models. Payment belongs to a client, which belongs to a contract, which belongs to a client, which belongs to a user. I was going to make an accessor like $this->contract->client->user->name but then I'd have an n+1 problem, right? So is this query override standard practice? How should this be handled in V3?
No description
Solution:
So. TextColumn::make(‘blah.name’) will display the name attribute on the blah relationship.
Jump to solution
5 Replies
awcodes
awcodes14mo ago
Don’t use ChatGPT for filament. It’s model is based on v1 and will therefore give you 0 relevant results for v2 let alone v3.
Emaz
EmazOP14mo ago
LOL yep that's why I asked.... so what do I do here? Isn't this an n+1 issue?
awcodes
awcodes14mo ago
You shouldn’t have to modify the query based on what little info I have. Dot syntax in the make() method on the column will eager load the relationships if they are set up correctly on the model.
Emaz
EmazOP14mo ago
So I can dot syntax all the way down the multiple relationships to get to the name?
Solution
awcodes
awcodes14mo ago
So. TextColumn::make(‘blah.name’) will display the name attribute on the blah relationship.
Want results from more Discord servers?
Add your server