F
Filament3mo ago
Tjiel

Change default table query to get only the soft deleted records

Hello all, For a project im working on I need my table results to only show the soft deleted records.
protected function getTableQuery(): Builder
{
return parent::getTableQuery();
}
protected function getTableQuery(): Builder
{
return parent::getTableQuery();
}
I want it so that instead of currently returning the default parent::getTableQuery instead a where or something like that that makes it so it only gets soft deleted records.
7 Replies
🎮Days🕹
🎮Days🕹3mo ago
can you try to add the where with "deleted_at" column NOT NULL or use the onlyTrashed() method on the model
toeknee
toeknee3mo ago
Use the trashed filter and apply trashed by default
Tjiel
Tjiel3mo ago
Ty for the replies I used the onlyTrashed method on the model like this:
return Collection::onlyTrashed();
return Collection::onlyTrashed();
toeknee
toeknee3mo ago
Plese read the docs? You can use the native filament trashed features then on the filter just set ->default is the trashed method
Tjiel
Tjiel3mo ago
I did read the docs and i already had tried the exact same thing earlier. The problem was that I had a default trashed filter where trashed was hidden.
toeknee
toeknee3mo ago
But if you apply the default trashed filter then within the filter options it’ll be applied by default
Tjiel
Tjiel3mo ago
Yeah I know that but, I have some logic in the getTableQuery() where it sometimes needs to show the trashed and sometimes it doesn't
Want results from more Discord servers?
Add your server
More Posts