$payload */ public function __construct( private readonly AlertDelivery $delivery, private readonly array $payload, ) {} /** * @return array */ public function via(object $notifiable): array { return ['mail']; } public function toMail(object $notifiable): MailMessage { $title = trim((string) ($this->payload['title'] ?? 'Alert')); $body = trim((string) ($this->payload['body'] ?? 'A matching alert event was detected.')); if ($title === '') { $title = 'Alert'; } if ($body === '') { $body = 'A matching alert event was detected.'; } return (new MailMessage) ->subject($title) ->line($body) ->line('Delivery ID: '.(int) $this->delivery->getKey()) ->line('Event type: '.(string) $this->delivery->event_type) ->line('Status: '.(string) $this->delivery->status); } }