refactor: extract dashboard filter reset logic into a dedicated method that also clears session filters.
This commit is contained in:
parent
c507d0f8ef
commit
3285fa196c
@ -44,11 +44,18 @@ protected function getHeaderActions(): array
|
||||
->label('Reset Filter')
|
||||
->icon(Heroicon::XMark)
|
||||
->color('danger')
|
||||
->action(function () {
|
||||
$this->filters['startDate'] = null;
|
||||
$this->filters['endDate'] = null;
|
||||
})
|
||||
->action(fn () => $this->resetFilters())
|
||||
->visible(fn () => ! empty($this->filters['startDate']) || ! empty($this->filters['endDate'])),
|
||||
];
|
||||
}
|
||||
|
||||
public function resetFilters(): void
|
||||
{
|
||||
$this->filters['startDate'] = null;
|
||||
$this->filters['endDate'] = null;
|
||||
|
||||
if (method_exists($this, 'getFiltersSessionKey')) {
|
||||
session()->forget($this->getFiltersSessionKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user