Modify the initial query when loading a table

In a Table is it possible to modify the initial query? In my case I want to only show Orders with sent = true; I don't want to see the other orders in this view. Can I change the query on what the table is based?
4 Replies
Tobias Platen
Tobias Platen5mo ago
Filters might be the better choice here.
Filter::make('is_sent')
->query(fn (Builder $query): Builder => $query->where('sent', true))
->default()
Filter::make('is_sent')
->query(fn (Builder $query): Builder => $query->where('sent', true))
->default()
If you modify the BaseQuery, you will never be able to view the other entries. With the filter, you can see all entries with just one click.
ChesterS
ChesterS5mo ago
You can also pass a custom query to the table itself AFAIK
return $table->query(...)
return $table->query(...)
JJSanders
JJSanders5mo ago
I didn't want a filter on purpose. For this view I want to have a specific Basequery. A specific request from the client