check if user accept notifications

This commit is contained in:
2026-03-26 10:29:51 +01:00
parent 83ec6c9a2a
commit 1d9c6726b3
3 changed files with 208 additions and 183 deletions
+26 -19
View File
@@ -97,28 +97,35 @@ class EventsController extends Controller
return $task->users;
})->unique('id');
if (Carbon::now()->lessThanOrEqualTo($event->end)) {
$notification = Notification::create([
'content' => "L'événement {$event->name} a été supprimé. Vous n'y participez donc plus."
]);
$notification->users()->attach($participants->pluck('id'));
$webParticipants = $participants->filter(fn($user) => $user->web_notifications);
if ($webParticipants->isNotEmpty()) {
$notification = Notification::create([
'content' => "L'événement {$event->name} a été supprimé. Vous n'y participez donc plus."
]);
$notification->users()->attach($webParticipants->pluck('id'));
foreach ($webParticipants as $user) {
broadcast(new EventParticipationCancelled(
$user->id,
$event,
$notification->id,
));
}
}
foreach ($participants as $user) {
broadcast(new EventParticipationCancelled(
$user->id,
$event,
$notification->id,
));
$data = [
'name' => $user->name,
'lastname' => $user->lastname,
'eventName' => $event->name,
'start' => $event->start,
'end' => $event->end,
];
Mail::to($user->email)->send(new EventParticipationCancelledMail($data));
if ($user->email_notifications) {
$data = [
'name' => $user->name,
'lastname' => $user->lastname,
'eventName' => $event->name,
'start' => $event->start,
'end' => $event->end,
];
Mail::to($user->email)->send(new EventParticipationCancelledMail($data));
}
}
}