check if user accept notifications
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user