From 3285fa196cf7c2ce5e08b3de9664d8f40708e158 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Thu, 29 Jan 2026 13:32:34 +0700 Subject: [PATCH] refactor: extract dashboard filter reset logic into a dedicated method that also clears session filters. --- app/Filament/Pages/Dashboard.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/Filament/Pages/Dashboard.php b/app/Filament/Pages/Dashboard.php index b179fe0..4a8ea26 100644 --- a/app/Filament/Pages/Dashboard.php +++ b/app/Filament/Pages/Dashboard.php @@ -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()); + } + } }