From 923b722ed3ec04a699a1ff2feff93b50f81b33e2 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Tue, 10 Mar 2026 11:25:17 +0700 Subject: [PATCH] feat: Implement various action classes for Filament, including BackAction, GoToDateAction, and cheerful actions for create, edit, delete, force delete, and restore functionalities. --- app/Filament/Actions/BackAction.php | 22 ++++++++++++ .../Actions/Cheerful/CreateAction.php | 18 ++++++++++ .../Actions/Cheerful/DeleteAction.php | 18 ++++++++++ app/Filament/Actions/Cheerful/EditAction.php | 18 ++++++++++ .../Actions/Cheerful/ForceDeleteAction.php | 18 ++++++++++ .../Actions/Cheerful/RestoreAction.php | 18 ++++++++++ app/Filament/Actions/DefaultBulkActions.php | 34 ++++++++++++++++++ app/Filament/Actions/GoToDateAction.php | 35 +++++++++++++++++++ 8 files changed, 181 insertions(+) create mode 100644 app/Filament/Actions/BackAction.php create mode 100644 app/Filament/Actions/Cheerful/CreateAction.php create mode 100644 app/Filament/Actions/Cheerful/DeleteAction.php create mode 100644 app/Filament/Actions/Cheerful/EditAction.php create mode 100644 app/Filament/Actions/Cheerful/ForceDeleteAction.php create mode 100644 app/Filament/Actions/Cheerful/RestoreAction.php create mode 100644 app/Filament/Actions/DefaultBulkActions.php create mode 100644 app/Filament/Actions/GoToDateAction.php diff --git a/app/Filament/Actions/BackAction.php b/app/Filament/Actions/BackAction.php new file mode 100644 index 0000000..a483718 --- /dev/null +++ b/app/Filament/Actions/BackAction.php @@ -0,0 +1,22 @@ +label('Kembali') + ->color('secondary') + ->outlined(); + } +} diff --git a/app/Filament/Actions/Cheerful/CreateAction.php b/app/Filament/Actions/Cheerful/CreateAction.php new file mode 100644 index 0000000..2bd97fc --- /dev/null +++ b/app/Filament/Actions/Cheerful/CreateAction.php @@ -0,0 +1,18 @@ +successNotification( + SystemNotification::create() + ); + } +} diff --git a/app/Filament/Actions/Cheerful/DeleteAction.php b/app/Filament/Actions/Cheerful/DeleteAction.php new file mode 100644 index 0000000..94dd337 --- /dev/null +++ b/app/Filament/Actions/Cheerful/DeleteAction.php @@ -0,0 +1,18 @@ +successNotification( + SystemNotification::delete() + ); + } +} diff --git a/app/Filament/Actions/Cheerful/EditAction.php b/app/Filament/Actions/Cheerful/EditAction.php new file mode 100644 index 0000000..9f622d5 --- /dev/null +++ b/app/Filament/Actions/Cheerful/EditAction.php @@ -0,0 +1,18 @@ +successNotification( + SystemNotification::update() + ); + } +} diff --git a/app/Filament/Actions/Cheerful/ForceDeleteAction.php b/app/Filament/Actions/Cheerful/ForceDeleteAction.php new file mode 100644 index 0000000..81c8ffc --- /dev/null +++ b/app/Filament/Actions/Cheerful/ForceDeleteAction.php @@ -0,0 +1,18 @@ +successNotification( + SystemNotification::forceDelete() + ); + } +} diff --git a/app/Filament/Actions/Cheerful/RestoreAction.php b/app/Filament/Actions/Cheerful/RestoreAction.php new file mode 100644 index 0000000..9205e5c --- /dev/null +++ b/app/Filament/Actions/Cheerful/RestoreAction.php @@ -0,0 +1,18 @@ +successNotification( + SystemNotification::restore() + ); + } +} diff --git a/app/Filament/Actions/DefaultBulkActions.php b/app/Filament/Actions/DefaultBulkActions.php new file mode 100644 index 0000000..ddfa462 --- /dev/null +++ b/app/Filament/Actions/DefaultBulkActions.php @@ -0,0 +1,34 @@ +modalHeading("Hapus {$entity} yang dipilih") + ->successNotification( + SystemNotification::bulkDelete() + ), + + ForceDeleteBulkAction::make() + ->modalHeading("Hapus {$entity} yang dipilih") + ->successNotification( + SystemNotification::bulkForceDelete() + ), + + RestoreBulkAction::make() + ->modalHeading("Pulihkan {$entity} yang dipilih") + ->successNotification( + SystemNotification::bulkRestore() + ), + ]; + } +} diff --git a/app/Filament/Actions/GoToDateAction.php b/app/Filament/Actions/GoToDateAction.php new file mode 100644 index 0000000..bdd8eff --- /dev/null +++ b/app/Filament/Actions/GoToDateAction.php @@ -0,0 +1,35 @@ +label('Lompat ke Tanggal') + ->icon('heroicon-o-calendar-days') + ->schema([ + DatePicker::make('date') + ->label('Pilih Tanggal') + ->placeholder(fn () => now()->addMonth(10)->format('l, d F Y')) + ->required() + ->native(false) + ->displayFormat('l, d F Y'), + ]) + ->action(function (array $data, $livewire) { + $livewire->setOption('date', $data['date']); + }) + ->modalWidth(Width::Large); + } +}