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')
|
->label('Reset Filter')
|
||||||
->icon(Heroicon::XMark)
|
->icon(Heroicon::XMark)
|
||||||
->color('danger')
|
->color('danger')
|
||||||
->action(function () {
|
->action(fn () => $this->resetFilters())
|
||||||
$this->filters['startDate'] = null;
|
|
||||||
$this->filters['endDate'] = null;
|
|
||||||
})
|
|
||||||
->visible(fn () => ! empty($this->filters['startDate']) || ! empty($this->filters['endDate'])),
|
->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