- Introduce `CheerfulNotification` utility class to standardize cheerful and expressive notifications across the application. - Refactor custom "Cheerful" actions (Create, Edit, Delete, etc.) and `DefaultBulkActions` to utilize the new utility class. - Update all `ToggleColumn` status updates in Master Data modules to use `CheerfulNotification::statusUpdated()`. - Replace inline `Notification::make()` calls in custom actions (Reply, Crawl News, Cooperation actions) and Resource Pages with `CheerfulNotification` methods. - Address various lint errors by standardizing the use of the `Auth` facade and improving type hinting for the authenticated `User` model.
160 lines
4.4 KiB
PHP
160 lines
4.4 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Support;
|
|
|
|
use Filament\Notifications\Notification;
|
|
|
|
class CheerfulNotification
|
|
{
|
|
/**
|
|
* Create a new notification instance.
|
|
*/
|
|
public static function make(): Notification
|
|
{
|
|
return Notification::make();
|
|
}
|
|
|
|
/**
|
|
* Notification for successful record creation.
|
|
*/
|
|
public static function create(): Notification
|
|
{
|
|
return self::make()
|
|
->title('Hore! Data Tersimpan 🎉✨')
|
|
->body('Data baru berhasil ditambahkan! Sistem sudah menyimpannya dengan aman. 🚀💪')
|
|
->success();
|
|
}
|
|
|
|
/**
|
|
* Notification for successful record update.
|
|
*/
|
|
public static function update(): Notification
|
|
{
|
|
return self::make()
|
|
->title('Mantap! Data Diperbarui ✅🔥')
|
|
->body('Perubahan berhasil disimpan! Data sekarang sudah up-to-date dan segar lagi. ✨👌')
|
|
->success();
|
|
}
|
|
|
|
/**
|
|
* Notification for successful record deletion (soft delete).
|
|
*/
|
|
public static function delete(): Notification
|
|
{
|
|
return self::make()
|
|
->title('Oke, Data Dihapus 🗑️👋')
|
|
->body('Data tersebut sudah berhasil dihapus dari sistem. Semuanya bersih dan rapi sekarang! 😊🚮')
|
|
->success();
|
|
}
|
|
|
|
/**
|
|
* Notification for successful permanent deletion.
|
|
*/
|
|
public static function forceDelete(): Notification
|
|
{
|
|
return self::make()
|
|
->title('Selamat Tinggal Selamanya 👋😢')
|
|
->body('Data telah dihapus permanen dan tidak bisa kembali. Semoga ini keputusan yang tepat! 🚮💨')
|
|
->success();
|
|
}
|
|
|
|
/**
|
|
* Notification for successful record restoration.
|
|
*/
|
|
public static function restore(): Notification
|
|
{
|
|
return self::make()
|
|
->title('Welcome Back! Data Pulih ♻️✨')
|
|
->body('Data berhasil dikembalikan! Hati-hati ya, jangan sampai terhapus lagi. 😉👍')
|
|
->success();
|
|
}
|
|
|
|
/**
|
|
* Notification for successful status change/toggle.
|
|
*/
|
|
public static function statusUpdated(?string $title = null, ?string $body = null): Notification
|
|
{
|
|
return self::make()
|
|
->title($title ?? 'Status Berubah! 🔄✨')
|
|
->body($body ?? 'Status data berhasil diperbarui. Perubahan langsung aktif ya! 👍')
|
|
->success();
|
|
}
|
|
|
|
/**
|
|
* Notification for successful bulk deletion.
|
|
*/
|
|
public static function bulkDelete(): Notification
|
|
{
|
|
return self::make()
|
|
->title('Oke, Banyak Data Dihapus 🗑️👋')
|
|
->body('Semua data yang dipilih berhasil dihapus. Sistem makin lega deh! 😊')
|
|
->success();
|
|
}
|
|
|
|
/**
|
|
* Notification for successful bulk permanent deletion.
|
|
*/
|
|
public static function bulkForceDelete(): Notification
|
|
{
|
|
return self::make()
|
|
->title('Bye Bye Semua! 👋🔥')
|
|
->body('Data yang dipilih sudah dihapus permanen. Bersih total! 🧹💨')
|
|
->success();
|
|
}
|
|
|
|
/**
|
|
* Notification for successful bulk restoration.
|
|
*/
|
|
public static function bulkRestore(): Notification
|
|
{
|
|
return self::make()
|
|
->title('Hore! Banyak Data Pulih ♻️🎉')
|
|
->body('Data-data tersebut sudah kembali aktif. Selamat bekerja kembali! 💪✨')
|
|
->success();
|
|
}
|
|
|
|
/**
|
|
* Custom cheerful success notification.
|
|
*/
|
|
public static function success(string $title, string $body): Notification
|
|
{
|
|
return self::make()
|
|
->title($title)
|
|
->body($body)
|
|
->success();
|
|
}
|
|
|
|
/**
|
|
* Custom cheerful info notification.
|
|
*/
|
|
public static function info(string $title, string $body): Notification
|
|
{
|
|
return self::make()
|
|
->title($title)
|
|
->body($body)
|
|
->info();
|
|
}
|
|
|
|
/**
|
|
* Custom cheerful warning notification.
|
|
*/
|
|
public static function warning(string $title, string $body): Notification
|
|
{
|
|
return self::make()
|
|
->title($title)
|
|
->body($body)
|
|
->warning();
|
|
}
|
|
|
|
/**
|
|
* Custom cheerful danger notification.
|
|
*/
|
|
public static function danger(string $title, string $body): Notification
|
|
{
|
|
return self::make()
|
|
->title($title)
|
|
->body($body)
|
|
->danger();
|
|
}
|
|
}
|