<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class FilamentNotificationEmail extends Notification
{
use Queueable;
protected \Filament\Notifications\Notification $filament_notification;
/**
* Create a new notification instance.
*/
public function __construct(\Filament\Notifications\Notification $filament_notification)
{
$this->filament_notification = $filament_notification;
}
/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*/
public function toMail(object $notifiable): MailMessage
{
$action = $this->filament_notification->getActions();
$action = $action[0] ?? null;
return (new MailMessage)
->subject($this->filament_notification->getTitle())
->greeting('Hello ' . $notifiable->name . ',')
->line($this->filament_notification->getBody())
->action($action ? $action->getLabel() : "Visit App", $action ? $action->getUrl() : env("APP_URL"));
}
/**
* Get the array representation of the notification.
*
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
//
];
}
}