172 lines
5.8 KiB
PHP
172 lines
5.8 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Support;
|
|
|
|
use App\Enums\UxStyle;
|
|
use Filament\Notifications\Notification;
|
|
|
|
class CheerfulNotification
|
|
{
|
|
/**
|
|
* Create a new notification instance.
|
|
*/
|
|
public static function make(): Notification
|
|
{
|
|
return Notification::make();
|
|
}
|
|
|
|
/**
|
|
* Get the current user's UX style preference.
|
|
*/
|
|
public static function getUxStyle(): UxStyle
|
|
{
|
|
try {
|
|
return auth()->user()?->settings?->ux_style ?? UxStyle::CHEERFUL;
|
|
} catch (\Throwable $e) {
|
|
return UxStyle::CHEERFUL;
|
|
}
|
|
}
|
|
|
|
public static function create(): Notification
|
|
{
|
|
$cheerful = self::getUxStyle() === UxStyle::CHEERFUL;
|
|
|
|
return self::make()
|
|
->title($cheerful ? 'Hore! Data Tersimpan 🎉✨' : 'Data Berhasil Disimpan')
|
|
->body($cheerful ? 'Data baru berhasil ditambahkan! Sistem sudah menyimpannya dengan aman. 🚀💪' : 'Data baru telah berhasil ditambahkan ke dalam sistem.')
|
|
->success();
|
|
}
|
|
|
|
public static function update(): Notification
|
|
{
|
|
$cheerful = self::getUxStyle() === UxStyle::CHEERFUL;
|
|
|
|
return self::make()
|
|
->title($cheerful ? 'Mantap! Data Diperbarui ✅🔥' : 'Perubahan Tersimpan')
|
|
->body($cheerful ? 'Perubahan berhasil disimpan! Data sekarang sudah up-to-date dan segar lagi. ✨👌' : 'Perubahan pada data telah berhasil diperbarui dan disimpan.')
|
|
->success();
|
|
}
|
|
|
|
public static function delete(): Notification
|
|
{
|
|
$cheerful = self::getUxStyle() === UxStyle::CHEERFUL;
|
|
|
|
return self::make()
|
|
->title($cheerful ? 'Oke, Data Dihapus 🗑️👋' : 'Data Dihapus')
|
|
->body($cheerful ? 'Data tersebut sudah berhasil dihapus dari sistem. Semuanya bersih dan rapi sekarang! 😊🚮' : 'Data tersebut telah berhasil dihapus dari sistem aplikasi.')
|
|
->success();
|
|
}
|
|
|
|
public static function forceDelete(): Notification
|
|
{
|
|
$cheerful = self::getUxStyle() === UxStyle::CHEERFUL;
|
|
|
|
return self::make()
|
|
->title($cheerful ? 'Selamat Tinggal Selamanya 👋😢' : 'Data Dihapus Permanen')
|
|
->body($cheerful ? 'Data telah dihapus permanen dan tidak bisa kembali. Semoga ini keputusan yang tepat! 🚮💨' : 'Data tersebut telah dihapus secara permanen dari sistem.')
|
|
->success();
|
|
}
|
|
|
|
public static function restore(): Notification
|
|
{
|
|
$cheerful = self::getUxStyle() === UxStyle::CHEERFUL;
|
|
|
|
return self::make()
|
|
->title($cheerful ? 'Welcome Back! Data Pulih ♻️✨' : 'Data Berhasil Dipulihkan')
|
|
->body($cheerful ? 'Data berhasil dikembalikan! Hati-hati ya, jangan sampai terhapus lagi. 😉👍' : 'Data yang dihapus sebelumnya telah berhasil dipulihkan ke dalam sistem.')
|
|
->success();
|
|
}
|
|
|
|
public static function statusUpdated(?string $title = null, ?string $body = null): Notification
|
|
{
|
|
$cheerful = self::getUxStyle() === UxStyle::CHEERFUL;
|
|
|
|
return self::make()
|
|
->title($title ?? ($cheerful ? 'Status Berubah! 🔄✨' : 'Status Diperbarui'))
|
|
->body($body ?? ($cheerful ? 'Status data berhasil diperbarui. Perubahan langsung aktif ya! 👍' : 'Status data telah berhasil diperbarui dan telah diterapkan.'))
|
|
->success();
|
|
}
|
|
|
|
public static function bulkDelete(): Notification
|
|
{
|
|
$cheerful = self::getUxStyle() === UxStyle::CHEERFUL;
|
|
|
|
return self::make()
|
|
->title($cheerful ? 'Oke, Banyak Data Dihapus 🗑️👋' : 'Data Berhasil Dihapus')
|
|
->body($cheerful ? 'Semua data yang dipilih berhasil dihapus. Sistem makin lega deh! 😊' : 'Seluruh data yang dipilih telah berhasil dihapus dari sistem.')
|
|
->success();
|
|
}
|
|
|
|
public static function bulkForceDelete(): Notification
|
|
{
|
|
$cheerful = self::getUxStyle() === UxStyle::CHEERFUL;
|
|
|
|
return self::make()
|
|
->title($cheerful ? 'Bye Bye Semua! 👋🔥' : 'Data Dihapus Permanen')
|
|
->body($cheerful ? 'Data yang dipilih sudah dihapus permanen. Bersih total! 🧹💨' : 'Data yang dipilih telah berhasil dihapus secara permanen.')
|
|
->success();
|
|
}
|
|
|
|
public static function bulkRestore(): Notification
|
|
{
|
|
$cheerful = self::getUxStyle() === UxStyle::CHEERFUL;
|
|
|
|
return self::make()
|
|
->title($cheerful ? 'Hore! Banyak Data Pulih ♻️🎉' : 'Data Berhasil Dipulihkan')
|
|
->body($cheerful ? 'Data-data tersebut sudah kembali aktif. Selamat bekerja kembali! 💪✨' : 'Seluruh data yang dipilih telah berhasil dikembalikan ke posisi semula.')
|
|
->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();
|
|
}
|
|
|
|
/**
|
|
* Get dynamic message based on UX style.
|
|
*/
|
|
public static function getMessage(string $cheerful, string $formal): string
|
|
{
|
|
return self::getUxStyle() === UxStyle::CHEERFUL ? $cheerful : $formal;
|
|
}
|
|
}
|