lms/app/Notifications/NewsletterNotification.php
2025-12-15 12:26:23 +01:00

55 lines
1.2 KiB
PHP

<?php
namespace App\Notifications;
use App\Models\Newsletter;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class NewsletterNotification extends Notification
{
use Queueable;
/**
* Create a new notification instance.
*/
public function __construct(private Newsletter $newsletter) {}
/**
* 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
{
return (new MailMessage)
->subject($this->newsletter->subject)
->view('mail.newsletter', [
'subject' => $this->newsletter->subject,
'description' => $this->newsletter->description,
]);
}
/**
* Get the array representation of the notification.
*
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
//
];
}
}