diff --git a/app/Listeners/TaskUpdateNotif.php b/app/Listeners/TaskUpdateNotif.php index 65981a2..118036c 100644 --- a/app/Listeners/TaskUpdateNotif.php +++ b/app/Listeners/TaskUpdateNotif.php @@ -8,8 +8,6 @@ use App\Models\User; use App\Notifications\DBNotification; use App\Notifications\FcmNotification; use App\Notifications\MailNotification; -use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Queue\InteractsWithQueue; use Illuminate\Support\Facades\Notification; class TaskUpdateNotif diff --git a/app/Utilities/HelperClass/NotificationHelper.php b/app/Utilities/HelperClass/NotificationHelper.php new file mode 100644 index 0000000..4231cbe --- /dev/null +++ b/app/Utilities/HelperClass/NotificationHelper.php @@ -0,0 +1,72 @@ + $this->getMessageLine($payload, $route.'greeting'), + 'subject' => $this->getMessageLine($payload, $route.'subject'), + 'title' => $this->getMessageLine($payload, $route.'title'), + 'body' => $this->getMessageLine($payload, $route.'body', $options) + ]; + } + + /** + * Fetch message from notifications lang file + * + * @param $payload + * @param $key + * @param null $options + * @return array|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Translation\Translator|string|null + * + */ + public function getMessageLine($payload, $key, $options = []) + { + return __('notification.'.$payload->data->table_name.'.'.enum('cruds.inverse.'.$payload->data->crud_id.'.singular_name').'.'.$key, $options); + } + + /** + * Call notifications + * + * @param $users + * @param $notif + */ + public function sendNotifications($users, $notif) { +// switch ($level) { +// case "emergency": +//// Notification::send($users, new SmsNotification($notif)); +// case "critical": +// Notification::send($users, new MailNotification($notif)); +// case "high": +// Notification::send($users, new DBNotification($notif)); +// case "medium": +// Notification::send($users, new FcmNotification($notif)); +// case "low": +//// Notification::send($users, new SocketNotification($notif)); +// default: +//// Notification::send($users, new SocketNotification($notif)); +// } + Notification::send($users, new MailNotification($notif)); + Notification::send($users, new DBNotification($notif)); + Notification::send($users, new FcmNotification($notif)); + } + +}