62 lines
1.6 KiB
PHP
62 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Notifications\Notification;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
|
|
class LaporanWorkflowNotification extends Notification
|
|
{
|
|
use Queueable;
|
|
|
|
public function __construct(
|
|
private readonly string $title,
|
|
private readonly string $message,
|
|
private readonly ?string $actionUrl = null,
|
|
private readonly ?string $actionLabel = null
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* Get the notification's delivery channels.
|
|
*
|
|
* @return array<int, string>
|
|
*/
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['database', 'mail'];
|
|
}
|
|
|
|
/**
|
|
* Get the mail representation of the notification.
|
|
*/
|
|
public function toMail(object $notifiable): MailMessage
|
|
{
|
|
return (new MailMessage)
|
|
->view('emails.kegiatan-workflow', [
|
|
'notifiable' => $notifiable,
|
|
'title' => $this->title,
|
|
'contentMessage' => $this->message,
|
|
'actionUrl' => $this->actionUrl,
|
|
'actionLabel' => $this->actionLabel ?? 'Buka',
|
|
])
|
|
->subject($this->title);
|
|
}
|
|
|
|
/**
|
|
* Get the array representation of the notification.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(object $notifiable): array
|
|
{
|
|
return [
|
|
'title' => $this->title,
|
|
'message' => $this->message,
|
|
'action_url' => $this->actionUrl,
|
|
'action_label' => $this->actionLabel ?? 'Lihat detail',
|
|
];
|
|
}
|
|
}
|