From 78e8de28d78a66e133d3c9d4ecb840833e369fdc Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Mon, 9 Feb 2026 08:45:47 +0700 Subject: [PATCH] feat: Add reusable Filament actions, bulk actions, and timestamp columns with custom cheerful notifications. --- 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/Columns/TimestampColumns.php | 34 +++++++++++++++++++ app/Filament/Pages/Auth/Login.php | 2 +- 9 files changed, 181 insertions(+), 1 deletion(-) 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/Columns/TimestampColumns.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..73f3cb8 --- /dev/null +++ b/app/Filament/Actions/Cheerful/CreateAction.php @@ -0,0 +1,18 @@ +successNotification( + CheerfulNotification::create() + ); + } +} diff --git a/app/Filament/Actions/Cheerful/DeleteAction.php b/app/Filament/Actions/Cheerful/DeleteAction.php new file mode 100644 index 0000000..18cd7fe --- /dev/null +++ b/app/Filament/Actions/Cheerful/DeleteAction.php @@ -0,0 +1,18 @@ +successNotification( + CheerfulNotification::delete() + ); + } +} diff --git a/app/Filament/Actions/Cheerful/EditAction.php b/app/Filament/Actions/Cheerful/EditAction.php new file mode 100644 index 0000000..1672243 --- /dev/null +++ b/app/Filament/Actions/Cheerful/EditAction.php @@ -0,0 +1,18 @@ +successNotification( + CheerfulNotification::update() + ); + } +} diff --git a/app/Filament/Actions/Cheerful/ForceDeleteAction.php b/app/Filament/Actions/Cheerful/ForceDeleteAction.php new file mode 100644 index 0000000..6690c69 --- /dev/null +++ b/app/Filament/Actions/Cheerful/ForceDeleteAction.php @@ -0,0 +1,18 @@ +successNotification( + CheerfulNotification::forceDelete() + ); + } +} diff --git a/app/Filament/Actions/Cheerful/RestoreAction.php b/app/Filament/Actions/Cheerful/RestoreAction.php new file mode 100644 index 0000000..de03fc9 --- /dev/null +++ b/app/Filament/Actions/Cheerful/RestoreAction.php @@ -0,0 +1,18 @@ +successNotification( + CheerfulNotification::restore() + ); + } +} diff --git a/app/Filament/Actions/DefaultBulkActions.php b/app/Filament/Actions/DefaultBulkActions.php new file mode 100644 index 0000000..eda71ec --- /dev/null +++ b/app/Filament/Actions/DefaultBulkActions.php @@ -0,0 +1,34 @@ +modalHeading("Hapus {$entity} yang dipilih") + ->successNotification( + CheerfulNotification::bulkDelete() + ), + + ForceDeleteBulkAction::make() + ->modalHeading("Hapus {$entity} yang dipilih") + ->successNotification( + CheerfulNotification::bulkForceDelete() + ), + + RestoreBulkAction::make() + ->modalHeading("Pulihkan {$entity} yang dipilih") + ->successNotification( + CheerfulNotification::bulkRestore() + ), + ]; + } +} diff --git a/app/Filament/Columns/TimestampColumns.php b/app/Filament/Columns/TimestampColumns.php new file mode 100644 index 0000000..0db19f9 --- /dev/null +++ b/app/Filament/Columns/TimestampColumns.php @@ -0,0 +1,34 @@ +label('Dibuat') + ->sortable() + ->toggleable(isToggledHiddenByDefault: true) + ->dateTime('l, d F Y H:i:s') + ->wrap(), + + TextColumn::make('updated_at') + ->label('Diperbarui') + ->sortable() + ->toggleable(isToggledHiddenByDefault: true) + ->dateTime('l, d F Y H:i:s') + ->wrap(), + + TextColumn::make('deleted_at') + ->label('Dihapus') + ->sortable() + ->toggleable(isToggledHiddenByDefault: true) + ->dateTime('l, d F Y H:i:s') + ->wrap(), + ]; + } +} diff --git a/app/Filament/Pages/Auth/Login.php b/app/Filament/Pages/Auth/Login.php index cfee65b..ccf1c8b 100644 --- a/app/Filament/Pages/Auth/Login.php +++ b/app/Filament/Pages/Auth/Login.php @@ -136,7 +136,7 @@ public function authenticate(): ?LoginResponse CheerfulNotification::success( 'Hore! Berhasil Masuk 🎉', - 'Selamat datang kembali, ' . $user->name . '! Siap untuk beraksi hari ini? 🚀✨' + 'Selamat datang kembali, '.$user->name.'! Siap untuk beraksi hari ini? 🚀✨' )->send(); return app(LoginResponse::class);