F
Filament6mo ago
harps

Query scoping

I have a model called survey that has a relationship to a model called pipe. Pipe has a json column for storing geojson as well as a WKT field for geometry calculations. I want to exclude the pipe field from being retrieved in filament to speed up page loading. I think it's automatically loaded in laravel with eager loading on the relationship. What's the best way to prevent retrieving those columns in Filament until I need them? Cheers Dan
4 Replies
harps
harpsOP6mo ago
Basically I want to prevent the "select * from" queries on my resource lists pages
Brian Kidd
Brian Kidd6mo ago
One way would be alter the query and define the fields from the pipe model that you want included. There may be a simpler way in filament but this is a way to do it with Eloquent: https://laravel.com/docs/11.x/eloquent-relationships#eager-loading-specific-columns
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
harps
harpsOP6mo ago
Thanks @Brian Kidd, I'll I look further into that and let you know. I have tried multiple ways to try and constrain the model but I'm either doing it wrong or Filament is doing it's own thing to allow the dot notation when accessing fields.
Brian Kidd
Brian Kidd6mo ago
Yes the dot notation will force that relationship to eager load
Want results from more Discord servers?
Add your server