Files
roxane/app/Notifications/SubscriptionExpiredPhase1.php

49 lines
1.2 KiB
PHP
Raw Normal View History

2026-02-08 21:59:16 +01:00
<?php
namespace App\Notifications;
use App\Models\NotificationTemplate;
2026-02-08 21:59:16 +01:00
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class SubscriptionExpiredPhase1 extends Notification implements ShouldQueue
{
use Queueable;
public function __construct(public readonly NotificationTemplate $template) {}
2026-02-08 21:59:16 +01:00
/**
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return ['mail'];
}
public function toMail(object $notifiable): MailMessage
{
$lastMembership = $notifiable->memberships()->latest()->first();
$vars = [
'member_name' => $notifiable->full_name,
'expiry_date' => $lastMembership?->end_date ?? '',
];
2026-02-08 21:59:16 +01:00
return (new MailMessage)
->subject($this->template->renderSubject($vars))
->view('notifications.mail-template', [
'body' => $this->template->renderBody($vars),
]);
2026-02-08 21:59:16 +01:00
}
/**
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [];
2026-02-08 21:59:16 +01:00
}
}