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?
Solution:Jump to solution
So. TextColumn::make(‘blah.name’) will display the name attribute on the blah relationship.
5 Replies
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.
LOL yep that's why I asked.... so what do I do here? Isn't this an n+1 issue?
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.
So I can dot syntax all the way down the multiple relationships to get to the name?
Solution
So. TextColumn::make(‘blah.name’) will display the name attribute on the blah relationship.