getEloquentQuery() is not respected when using Live()
In a resource page, after live() is triggered, the page is reloaded with the wrong model query. How do I keep the query the same after live()?
Image 1 is on initial page load (respects getEloquentQuery()). Image 2 is after live().


8 Replies
Can you share some code?
Hi Dennis, here is the small amount of code needed to reproduce this issue. This is on a fresh installation of filament 3 on php 8.3.
Here is the query on page load (respecting geteloquentquery())

here is the query on page refresh after the live checkbox is clicked

Why are you doing that:
return parent::getEloquentQuery()->select('id', 'name');
The reason it changes is likely because you haven't defined the columns and the selects are removed if the columns no longer exist.
If you add the columns but add a where into the eloquent query does it respect the additional where?
Also your live is on a form and the form isn't really part of the eloquent query, since the eloquent query should be run but be part of the table.
I'm using ->select because the database table I'm working with has a lot of columns and I would like to reduce the size of the query if possible. It does respect the ->where, interestingly enough. Why does it not keep the ->select? The columns are defined on the SQL side but is there another place I need to define them?
So you can replace the query by using ->query(fn($query) => $query->select()) on the table it's self which removes the eloquent query function. Does that stay as expected? I suspect the query is replaced in the table because of column selection by default
->query(fn($query) => $query->select()) results in
I tried this with ->modifyQueryUsing() and it modified the query for the table fine, but not the form.
It says here that using getEloquentQuery() should apply to the entire resource, though. Which it does...until live() is triggered
