Deleted_at from and until with TrashedFilter

Hey! I was wondering if anyone have done this before or have had this issue but any help will be much appreciate it!

I have a resource that has a TrashedFilter filter.
I'm trying to implement another filter that will filter results by deleted_at from and deleted_at until.

it seems that the filter works but only if I apply the trashedFilter 'only deleted records'
is there a way that I can manually set that value when the deleted_from It's being used?
I thought in removing the trashed filter but that led to more issues like it will display the deleted records.

Here is the idea:

TrashedFilter::make(),
Filter::make('deleted_date_range')
->form([
DateTimePicker::make('deleted_from'),
DateTimePicker::make('deleted_until'),
])
->query(function ($query, array $data) {
if ($data['deleted_from'] || $data['deleted_until']) {
// Explicitly include only soft-deleted records doesn’t work
$query->onlyTrashed();

if ($data['deleted_from']) {
$query->whereDate('deleted_at', '>=', $data['deleted_from']);
}

if ($data['deleted_until']) {
$query->whereDate('deleted_at', '<=', $data['deleted_until']);
}
}

return $query;
}),
]))

public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}

Any other options or ideas will be very helpfull! thank you in advance!!
Solution
@Dennis Koch thank you very much! That did gave me an idea!

For anyone facing this issue or anything similar you can get a filters value using:

$livewire->getTableFilterState($filterName)

I ended up creating my own trashedFilter in which the default if (filter was set) just return the $query else $query->withoutTrashed()
Was this page helpful?