Files
SAE-BUT2-backend/app/Notifications/EventDeleted.php
T
2026-07-15 18:51:43 +02:00

44 lines
1.1 KiB
PHP
Executable File

<?php
namespace App\Notifications;
use App\Mail\EventParticipationCancelledMail;
use App\Models\Event;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Notifications\Messages\BroadcastMessage;
use Illuminate\Support\Facades\Mail;
class EventDeleted extends Notification implements ShouldBroadcast
{
use Queueable;
public function __construct(public Event $event) {}
public function via($notifiable): array
{
$channels = [];
if ($notifiable->web_notifications) {
$channels[] = 'database';
$channels[] = 'broadcast';
}
return $channels;
}
public function toDatabase($notifiable): array
{
return [
'message' => "L'événement {$this->event->name} a été supprimé. Vous n'y participez donc plus.",
'event_id' => $this->event->id,
];
}
public function toBroadcast($notifiable): BroadcastMessage
{
return new BroadcastMessage($this->toDatabase($notifiable));
}
}