+ Cet email a été envoyé automatiquement, merci de ne pas y répondre.
+
+
+
From 6c679596bdc8b93b8282cf087a3d27707f003d1f Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Wed, 18 Mar 2026 16:18:12 +0100
Subject: [PATCH 33/63] add date to eventParticipationCancelled mail
---
app/Http/Controllers/EventsController.php | 2 ++
app/Mail/EventParticipationCancelledMail.php | 2 ++
resources/views/mails/eventParticipationCancelled.blade.php | 2 +-
resources/views/mails/volunteerUnassignToTask.blade.php | 2 +-
4 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/app/Http/Controllers/EventsController.php b/app/Http/Controllers/EventsController.php
index 2aed09d..9a321fc 100644
--- a/app/Http/Controllers/EventsController.php
+++ b/app/Http/Controllers/EventsController.php
@@ -108,6 +108,8 @@ class EventsController extends Controller
'name' => $user->name,
'lastname' => $user->lastname,
'eventName' => $event->name,
+ 'start' => $event->start,
+ 'end' => $event->end,
];
Mail::to($user->email)->send(new EventParticipationCancelledMail($data));
diff --git a/app/Mail/EventParticipationCancelledMail.php b/app/Mail/EventParticipationCancelledMail.php
index 2b73159..1255c67 100644
--- a/app/Mail/EventParticipationCancelledMail.php
+++ b/app/Mail/EventParticipationCancelledMail.php
@@ -43,6 +43,8 @@ class EventParticipationCancelledMail extends Mailable
'name' => $this->data['name'],
'lastname' => $this->data['lastname'],
'eventName' => $this->data['eventName'],
+ 'start' => $this->data['start'],
+ 'end' => $this->data['end'],
]
);
}
diff --git a/resources/views/mails/eventParticipationCancelled.blade.php b/resources/views/mails/eventParticipationCancelled.blade.php
index 2c2c8c6..6a0d352 100644
--- a/resources/views/mails/eventParticipationCancelled.blade.php
+++ b/resources/views/mails/eventParticipationCancelled.blade.php
@@ -11,7 +11,7 @@
L’événement {{ $eventName }} a été supprimé par un administrateur.
- Vous n’y participez donc plus.
+ Vous n’y participez donc plus. Cet événement avait lieu de {{ $start }} à {{ $end }}.
diff --git a/resources/views/mails/volunteerUnassignToTask.blade.php b/resources/views/mails/volunteerUnassignToTask.blade.php
index 115747f..d8f65dd 100644
--- a/resources/views/mails/volunteerUnassignToTask.blade.php
+++ b/resources/views/mails/volunteerUnassignToTask.blade.php
@@ -11,7 +11,7 @@
Vous avez été désassigné de la tâche {{ $taskName }} par un administrateur.
- Cette tâche avait lieu de {{ $start }} à {{ $end }}. Vous n'y participez donc plus.
+ Vous n'y participez donc plus. Cette tâche avait lieu de {{ $start }} à {{ $end }}.
From 2ca3100b3c70cc14f837f3d2f3c24b53853dfae9 Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Wed, 18 Mar 2026 16:30:13 +0100
Subject: [PATCH 34/63] create a formatDate service and method
---
app/Services/FormatDate.php | 13 +++++++++++++
1 file changed, 13 insertions(+)
create mode 100644 app/Services/FormatDate.php
diff --git a/app/Services/FormatDate.php b/app/Services/FormatDate.php
new file mode 100644
index 0000000..aece902
--- /dev/null
+++ b/app/Services/FormatDate.php
@@ -0,0 +1,13 @@
+format('d/m/Y, H:i');
+ }
+
+}
From 400d70ff7e9579655f6235f22589340d6a4a2147 Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Wed, 18 Mar 2026 16:30:27 +0100
Subject: [PATCH 35/63] use formatDate method
---
app/Http/Controllers/TasksController.php | 2 ++
app/Mail/EventParticipationCancelledMail.php | 5 +++--
app/Mail/TaskParticipationCancelledMail.php | 3 +++
app/Mail/VolunteerAssignToTaskMail.php | 5 +++--
app/Mail/VolunteerUnassignToTaskMail.php | 5 +++--
resources/views/mails/eventParticipationCancelled.blade.php | 2 +-
resources/views/mails/taskParticipationCancelled.blade.php | 2 +-
resources/views/mails/volunteerAssignToTask.blade.php | 2 +-
resources/views/mails/volunteerUnassignToTask.blade.php | 2 +-
9 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/app/Http/Controllers/TasksController.php b/app/Http/Controllers/TasksController.php
index f57199c..74c06e6 100644
--- a/app/Http/Controllers/TasksController.php
+++ b/app/Http/Controllers/TasksController.php
@@ -158,6 +158,8 @@ class TasksController extends Controller
'name' => $user->name,
'lastname' => $user->lastname,
'taskName' => $task->name,
+ 'start' => $event->start,
+ 'end' => $task->end,
];
Mail::to($user->email)->send(new TaskParticipationCancelledMail($data));
}
diff --git a/app/Mail/EventParticipationCancelledMail.php b/app/Mail/EventParticipationCancelledMail.php
index 1255c67..bcb8e7a 100644
--- a/app/Mail/EventParticipationCancelledMail.php
+++ b/app/Mail/EventParticipationCancelledMail.php
@@ -2,6 +2,7 @@
namespace App\Mail;
+use App\Services\FormatDate;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
@@ -43,8 +44,8 @@ class EventParticipationCancelledMail extends Mailable
'name' => $this->data['name'],
'lastname' => $this->data['lastname'],
'eventName' => $this->data['eventName'],
- 'start' => $this->data['start'],
- 'end' => $this->data['end'],
+ 'start' => FormatDate::formatDate($this->data['start']),
+ 'end' => FormatDate::formatDate($this->data['end']),
]
);
}
diff --git a/app/Mail/TaskParticipationCancelledMail.php b/app/Mail/TaskParticipationCancelledMail.php
index 9e59614..7eeacaf 100644
--- a/app/Mail/TaskParticipationCancelledMail.php
+++ b/app/Mail/TaskParticipationCancelledMail.php
@@ -2,6 +2,7 @@
namespace App\Mail;
+use App\Services\FormatDate;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
@@ -43,6 +44,8 @@ class TaskParticipationCancelledMail extends Mailable
'name' => $this->data['name'],
'lastname' => $this->data['lastname'],
'taskName' => $this->data['taskName'],
+ 'end' => FormatDate::formatDate($this->data['end']),
+ 'start' => FormatDate::formatDate($this->data['start']),
]
);
}
diff --git a/app/Mail/VolunteerAssignToTaskMail.php b/app/Mail/VolunteerAssignToTaskMail.php
index a190c78..99c722b 100644
--- a/app/Mail/VolunteerAssignToTaskMail.php
+++ b/app/Mail/VolunteerAssignToTaskMail.php
@@ -2,6 +2,7 @@
namespace App\Mail;
+use App\Services\FormatDate;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
@@ -43,8 +44,8 @@ class VolunteerAssignToTaskMail extends Mailable
'name' => $this->data['name'],
'lastname' => $this->data['lastname'],
'taskName' => $this->data['taskName'],
- 'start' => $this->data['start'],
- 'end' => $this->data['end'],
+ 'start' => FormatDate::formatDate($this->data['start']),
+ 'end' => FormatDate::formatDate($this->data['end']),
]
);
}
diff --git a/app/Mail/VolunteerUnassignToTaskMail.php b/app/Mail/VolunteerUnassignToTaskMail.php
index 7af6317..506d0c3 100644
--- a/app/Mail/VolunteerUnassignToTaskMail.php
+++ b/app/Mail/VolunteerUnassignToTaskMail.php
@@ -8,6 +8,7 @@ use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
+use App\Services\FormatDate;
class VolunteerUnassignToTaskMail extends Mailable
{
@@ -43,8 +44,8 @@ class VolunteerUnassignToTaskMail extends Mailable
'name' => $this->data['name'],
'lastname' => $this->data['lastname'],
'taskName' => $this->data['taskName'],
- 'start' => $this->data['start'],
- 'end' => $this->data['end'],
+ 'start' => FormatDate::formatDate($this->data['start']),
+ 'end' => FormatDate::formatDate($this->data['end']),
]
);
}
diff --git a/resources/views/mails/eventParticipationCancelled.blade.php b/resources/views/mails/eventParticipationCancelled.blade.php
index 6a0d352..9d2a4c2 100644
--- a/resources/views/mails/eventParticipationCancelled.blade.php
+++ b/resources/views/mails/eventParticipationCancelled.blade.php
@@ -11,7 +11,7 @@
L’événement {{ $eventName }} a été supprimé par un administrateur.
- Vous n’y participez donc plus. Cet événement avait lieu de {{ $start }} à {{ $end }}.
+ Vous n’y participez donc plus. Cet événement avait lieu du {{ $start }} au {{ $end }}.
diff --git a/resources/views/mails/taskParticipationCancelled.blade.php b/resources/views/mails/taskParticipationCancelled.blade.php
index a6e287a..861520c 100644
--- a/resources/views/mails/taskParticipationCancelled.blade.php
+++ b/resources/views/mails/taskParticipationCancelled.blade.php
@@ -11,7 +11,7 @@
La tâche {{ $taskName }} a été supprimé par un administrateur.
- Vous n’y participez donc plus.
+ Vous n’y participez donc plus. Cette tâche avait lieu du {{ $start }} au {{ $end }}.
diff --git a/resources/views/mails/volunteerAssignToTask.blade.php b/resources/views/mails/volunteerAssignToTask.blade.php
index cfebaba..55c4057 100644
--- a/resources/views/mails/volunteerAssignToTask.blade.php
+++ b/resources/views/mails/volunteerAssignToTask.blade.php
@@ -11,7 +11,7 @@
Vous avez été assigné à la tâche {{ $taskName }} par un administrateur.
- Cette tâche aura lieu de {{ $start }} à {{ $end }}.
+ Cette tâche aura lieu du {{ $start }} au {{ $end }}.
diff --git a/resources/views/mails/volunteerUnassignToTask.blade.php b/resources/views/mails/volunteerUnassignToTask.blade.php
index d8f65dd..052c68e 100644
--- a/resources/views/mails/volunteerUnassignToTask.blade.php
+++ b/resources/views/mails/volunteerUnassignToTask.blade.php
@@ -11,7 +11,7 @@
Vous avez été désassigné de la tâche {{ $taskName }} par un administrateur.
- Vous n'y participez donc plus. Cette tâche avait lieu de {{ $start }} à {{ $end }}.
+ Vous n'y participez donc plus. Cette tâche avait lieu du {{ $start }} au {{ $end }}.
From 69660270965a641f055451890775fe0808a6f9be Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 19 Mar 2026 08:41:07 +0100
Subject: [PATCH 36/63] check if the event is future or ongoing to send email
and notification on deletion
---
app/Http/Controllers/EventsController.php | 33 ++++++++++++-----------
1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/app/Http/Controllers/EventsController.php b/app/Http/Controllers/EventsController.php
index 9a321fc..e12d8b8 100644
--- a/app/Http/Controllers/EventsController.php
+++ b/app/Http/Controllers/EventsController.php
@@ -4,7 +4,6 @@ namespace App\Http\Controllers;
use App\Events\EventParticipationCancelled;
use App\Mail\EventParticipationCancelledMail;
-use App\Mail\ValidateMail;
use App\Models\Events;
use App\Models\Task;
use Illuminate\Http\Request;
@@ -12,6 +11,7 @@ use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
+use Carbon\Carbon;
class EventsController extends Controller
@@ -89,6 +89,8 @@ class EventsController extends Controller
try {
$event = Events::with('tasks.users')->find($id);
+ Log::info($event);
+ Log::info($event->tasks);
if (!$event) {
return response()->json(['message' => 'Event not found'], 404);
@@ -98,21 +100,22 @@ class EventsController extends Controller
return $task->users;
})->unique('id');
- foreach ($participants as $user) {
- broadcast(new EventParticipationCancelled(
- $user->id,
- $event
- ));
-
- $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 (Carbon::now()->lessThanOrEqualTo($event->end)) {
+ foreach ($participants as $user) {
+ broadcast(new EventParticipationCancelled(
+ $user->id,
+ $event
+ ));
+ $data = [
+ 'name' => $user->name,
+ 'lastname' => $user->lastname,
+ 'eventName' => $event->name,
+ 'start' => $event->start,
+ 'end' => $event->end,
+ ];
+ Mail::to($user->email)->send(new EventParticipationCancelledMail($data));
+ }
}
$event->delete();
From 77d3efc5557ba73d7447ec0220924ba9d385ed49 Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 19 Mar 2026 08:42:20 +0100
Subject: [PATCH 37/63] check if the task is future or ongoing to send email
and notification on deletion
---
app/Http/Controllers/TasksController.php | 31 +++++++++++++-----------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/app/Http/Controllers/TasksController.php b/app/Http/Controllers/TasksController.php
index 74c06e6..30c061e 100644
--- a/app/Http/Controllers/TasksController.php
+++ b/app/Http/Controllers/TasksController.php
@@ -10,6 +10,7 @@ use App\Mail\VolunteerUnassignToTaskMail;
use App\Models\Events;
use App\Models\Task;
use App\Models\User;
+use Carbon\Carbon;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;
@@ -147,21 +148,23 @@ class TasksController extends Controller
$participants = $task->users;
- foreach ($participants as $user) {
- broadcast(new TaskParticipationCancelled(
- $user->id,
- $task,
- $event
- ));
+ if (Carbon::now()->lessThanOrEqualTo($task->end)) {
+ foreach ($participants as $user) {
+ broadcast(new TaskParticipationCancelled(
+ $user->id,
+ $task,
+ $event
+ ));
- $data = [
- 'name' => $user->name,
- 'lastname' => $user->lastname,
- 'taskName' => $task->name,
- 'start' => $event->start,
- 'end' => $task->end,
- ];
- Mail::to($user->email)->send(new TaskParticipationCancelledMail($data));
+ $data = [
+ 'name' => $user->name,
+ 'lastname' => $user->lastname,
+ 'taskName' => $task->name,
+ 'start' => $event->start,
+ 'end' => $task->end,
+ ];
+ Mail::to($user->email)->send(new TaskParticipationCancelledMail($data));
+ }
}
$task->delete();
From 5d256637ecfcd184417465572bafa1dd36668d3e Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 19 Mar 2026 08:43:53 +0100
Subject: [PATCH 38/63] check if the task is future or ongoing to send email
and notification on assign user
---
app/Http/Controllers/TasksController.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/Http/Controllers/TasksController.php b/app/Http/Controllers/TasksController.php
index 30c061e..abb76bf 100644
--- a/app/Http/Controllers/TasksController.php
+++ b/app/Http/Controllers/TasksController.php
@@ -91,7 +91,7 @@ class TasksController extends Controller
$user = User::find($id);
- if($user) {
+ if($user && Carbon::now()->lessThanOrEqualTo($task->end)) {
$task->users()->attach($id);
broadcast(new VolunteerAssignedToTask(
From ad6a0f6e90e44ee0aeb2d546eed0dd0dd9f2b4fc Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 19 Mar 2026 08:44:12 +0100
Subject: [PATCH 39/63] check if the task is future or ongoing to send email
and notification on unassign user
---
app/Http/Controllers/TasksController.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/Http/Controllers/TasksController.php b/app/Http/Controllers/TasksController.php
index abb76bf..b456470 100644
--- a/app/Http/Controllers/TasksController.php
+++ b/app/Http/Controllers/TasksController.php
@@ -242,7 +242,7 @@ class TasksController extends Controller
$user = User::find($id);
- if ($user) {
+ if ($user && Carbon::now()->lessThanOrEqualTo($task->end)) {
$task->users()->detach($id);
broadcast(new VolunteerUnassignedFromTask(
From 0e5d6a12704b04dcc54c12e31d92bf9b17de9e60 Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 19 Mar 2026 10:00:18 +0100
Subject: [PATCH 40/63] merge dev into features/notifications
---
config/cors.php | 4 ----
1 file changed, 4 deletions(-)
diff --git a/config/cors.php b/config/cors.php
index 8287cbf..19f2551 100644
--- a/config/cors.php
+++ b/config/cors.php
@@ -20,13 +20,9 @@ return [
'allowed_methods' => ['*'],
-<<<<<<< HEAD
'allowed_origins' => env('DEV', 0) == 1
? explode(',', env('DEV_CORS_ALLOWED_ORIGINS'))
: explode(',', env('PROD_CORS_ALLOWED_ORIGINS')),
-=======
- 'allowed_origins' => ['*'],
->>>>>>> dev
'allowed_origins_patterns' => [],
From 4ebb1ad6c0419431da4fc2f6dc657d6549a6a544 Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 19 Mar 2026 10:22:59 +0100
Subject: [PATCH 41/63] fix attribut name
---
app/Http/Controllers/EventsController.php | 4 +---
app/Http/Controllers/TasksController.php | 2 +-
app/Models/Event.php | 2 +-
database/migrations/2025_11_09_144248_create_tasks_table.php | 2 +-
4 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/app/Http/Controllers/EventsController.php b/app/Http/Controllers/EventsController.php
index d369ccd..3789467 100644
--- a/app/Http/Controllers/EventsController.php
+++ b/app/Http/Controllers/EventsController.php
@@ -68,9 +68,8 @@ class EventsController extends Controller
}
public function getEvents(Request $request): JsonResponse {
-
+ Log::info('ok');
try {
-
$events = Event::with('tasks')->get();
return response()->json(['data' => $events]);
@@ -132,7 +131,6 @@ class EventsController extends Controller
}
public function getEvent(Request $request, int $id): JsonResponse {
-
try {
$event = Event::find($id);
diff --git a/app/Http/Controllers/TasksController.php b/app/Http/Controllers/TasksController.php
index 7b0a604..d9626d9 100644
--- a/app/Http/Controllers/TasksController.php
+++ b/app/Http/Controllers/TasksController.php
@@ -29,7 +29,7 @@ class TasksController extends Controller
try {
- $event = Event::find($request["event_id"]);
+ $event = Event::find($request["events_id"]);
$event->tasks()->create([
"name" => $request["name"],
diff --git a/app/Models/Event.php b/app/Models/Event.php
index 8709fb0..b4feeef 100644
--- a/app/Models/Event.php
+++ b/app/Models/Event.php
@@ -16,6 +16,6 @@ class Event extends Model
];
public function tasks() {
- return $this->hasMany(Task::class);
+ return $this->hasMany(Task::class, 'events_id');
}
}
diff --git a/database/migrations/2025_11_09_144248_create_tasks_table.php b/database/migrations/2025_11_09_144248_create_tasks_table.php
index b8c6363..e6ce615 100644
--- a/database/migrations/2025_11_09_144248_create_tasks_table.php
+++ b/database/migrations/2025_11_09_144248_create_tasks_table.php
@@ -21,7 +21,7 @@ return new class extends Migration
$table->dateTime("end");
$table->integer('max_participants');
- $table->foreignId("event_id")->constrained("events")->onDelete("cascade");
+ $table->foreignId("events_id")->constrained("events")->onDelete("cascade");
$table->timestamps();
});
From bda5aa4d508ffb41a89179a0b9ede34d87bbdf03 Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 19 Mar 2026 17:02:27 +0100
Subject: [PATCH 42/63] remove debug Log::info
---
app/Http/Controllers/EventsController.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/Http/Controllers/EventsController.php b/app/Http/Controllers/EventsController.php
index 3789467..117398e 100644
--- a/app/Http/Controllers/EventsController.php
+++ b/app/Http/Controllers/EventsController.php
@@ -68,7 +68,6 @@ class EventsController extends Controller
}
public function getEvents(Request $request): JsonResponse {
- Log::info('ok');
try {
$events = Event::with('tasks')->get();
From 16ae03e6e69e29a6513bce1b719ba6222e6c8aed Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 19 Mar 2026 17:11:34 +0100
Subject: [PATCH 43/63] create broadcast notification when the user role is
updated
---
app/Events/VolunteerRoleUpdated.php | 45 +++++++++++++++++++++++++
app/Http/Controllers/UserController.php | 8 ++++-
2 files changed, 52 insertions(+), 1 deletion(-)
create mode 100644 app/Events/VolunteerRoleUpdated.php
diff --git a/app/Events/VolunteerRoleUpdated.php b/app/Events/VolunteerRoleUpdated.php
new file mode 100644
index 0000000..e73bd47
--- /dev/null
+++ b/app/Events/VolunteerRoleUpdated.php
@@ -0,0 +1,45 @@
+userId = $userId;
+ $this->role = $role;
+ }
+
+ /**
+ * Get the channels the event should broadcast on.
+ *
+ * @return array
+ */
+ public function broadcastOn(): array
+ {
+ return [
+ new PrivateChannel('user.' . $this->userId),
+ ];
+ }
+
+ public function broadcastAs()
+ {
+ return 'volunteer.role.updated';
+ }
+}
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index d93a542..f58ba6b 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use App\Events\UserCreated;
+use App\Events\VolunteerRoleUpdated;
use App\Mail\CreateUserByAdminMail;
use App\Mail\DeactivateAccountMail;
use App\Mail\DeleteAccountMail;
@@ -255,10 +256,15 @@ class UserController extends Controller
$role = \App\Services\GetRole::getRole($request['role']);
$notification = Notification::create([
- 'content' => "Votre rôle à changé pour {$role} !",
+ 'content' => "Votre rôle à changé pour : {$role} !",
]);
$notification->users()->attach($user->id);
+ broadcast(new VolunteerRoleUpdated(
+ $user->id,
+ $role
+ ));
+
$data = [
'name' => $user->name,
'lastname' => $user->lastname,
From 6a825db6081c4557093c452cd9ff2735a7f14491 Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 19 Mar 2026 17:37:55 +0100
Subject: [PATCH 44/63] create notification, broadcast notification and mail
when a futur or ongoing date of a task is updated
---
app/Events/TaskDateUpdated.php | 45 +++++++++++++
app/Http/Controllers/TasksController.php | 47 ++++++++++++--
app/Mail/TaskDateUpdateMail.php | 64 +++++++++++++++++++
.../views/mails/taskDateUpdate.blade.php | 32 ++++++++++
4 files changed, 184 insertions(+), 4 deletions(-)
create mode 100644 app/Events/TaskDateUpdated.php
create mode 100644 app/Mail/TaskDateUpdateMail.php
create mode 100644 resources/views/mails/taskDateUpdate.blade.php
diff --git a/app/Events/TaskDateUpdated.php b/app/Events/TaskDateUpdated.php
new file mode 100644
index 0000000..af928d2
--- /dev/null
+++ b/app/Events/TaskDateUpdated.php
@@ -0,0 +1,45 @@
+userId = $userId;
+ $this->task = $task;
+ }
+
+ /**
+ * Get the channels the event should broadcast on.
+ *
+ * @return array
+ */
+ public function broadcastOn(): array
+ {
+ return [
+ new PrivateChannel('user.' . $this->userId),
+ ];
+ }
+
+ public function broadcastAs()
+ {
+ return 'task.date.updated';
+ }
+}
diff --git a/app/Http/Controllers/TasksController.php b/app/Http/Controllers/TasksController.php
index d9626d9..e5a90d7 100644
--- a/app/Http/Controllers/TasksController.php
+++ b/app/Http/Controllers/TasksController.php
@@ -2,9 +2,11 @@
namespace App\Http\Controllers;
+use App\Events\TaskDateUpdated;
use App\Events\TaskParticipationCancelled;
use App\Events\VolunteerAssignedToTask;
use App\Events\VolunteerUnassignedFromTask;
+use App\Mail\TaskDateUpdateMail;
use App\Models\Event;
use App\Models\Notification;
use App\Mail\VolunteerAssignToTaskMail;
@@ -18,6 +20,7 @@ use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use App\Mail\TaskParticipationCancelledMail;
+use App\Services\FormatDate;
class TasksController extends Controller
{
@@ -80,7 +83,7 @@ class TasksController extends Controller
try {
$task = Task::find($request["task_id"]);
- $event = \App\Models\Event::find($task->events_id);
+ $event = Event::find($task->events_id);
if ($task->users()->where('user_id', $id)->exists()) {
return response()->json(["message" => "User already assigned to this task"], 400);
@@ -112,6 +115,7 @@ class TasksController extends Controller
'taskName' => $task->name,
'start' => $task->start,
'end' => $task->end,
+ 'eventName' => $event->name,
];
Mail::to($user->email)->send(new VolunteerAssignToTaskMail($data));
}
@@ -146,7 +150,7 @@ class TasksController extends Controller
try {
$task = Task::with(['users'])->find($id);
- $event = \App\Models\Event::find($task->events_id);
+ $event = Event::find($task->events_id);
if (!$task) {
return response()->json(["message" => "Task not found"], 404);
@@ -175,6 +179,7 @@ class TasksController extends Controller
'taskName' => $task->name,
'start' => $event->start,
'end' => $task->end,
+ 'eventName' => $event->name,
];
Mail::to($user->email)->send(new TaskParticipationCancelledMail($data));
}
@@ -197,8 +202,41 @@ class TasksController extends Controller
}
try {
-
$task = Task::find($id);
+ if((
+ $task->start !== $request["start"] || $task->end !== $request["end"]
+ ) &&
+ Carbon::now()->lessThanOrEqualTo($task->end)
+ ){
+ $participants = $task->users;
+ $formatedTaskStart = FormatDate::formatDate($task->start);
+ $formatedTaskEnd = FormatDate::formatDate($task->end);
+ $event = Event::find($task->events_id);
+
+ foreach ($participants as $user) {
+ $notification = Notification::create([
+ 'content' => "La date de la tâche {$task->title} de l'événement {$task->event->name} à été mis à jour. Cette tâche aura maintenant lieu du {$formatedTaskStart} au {$formatedTaskEnd}."
+ ]);
+ $notification->users()->attach($user->id);
+ broadcast(new TaskDateUpdated(
+ $user->id,
+ $task,
+ ));
+
+ $data = [
+ 'name' => $user->name,
+ 'lastname' => $user->lastname,
+ 'taskName' => $task->name,
+ 'oldStart' => $formatedTaskStart,
+ 'oldEnd' => $formatedTaskEnd,
+ 'newStart' => $request["start"],
+ 'newEnd' => $request["end"],
+ 'eventName' => $event->name,
+ ];
+ Mail::to($user->email)->send(new TaskDateUpdateMail($data));
+ }
+ }
+
$task->name = $request["name"];
$task->description = $request["description"];
$task->start = $request["start"];
@@ -242,7 +280,7 @@ class TasksController extends Controller
try {
$task = Task::find($request["task_id"]);
- $event = \App\Models\Event::find($task->events_id);
+ $event = Event::find($task->events_id);
if (!$task) {
return response()->json(["message" => "Task not found"], 404);
@@ -273,6 +311,7 @@ class TasksController extends Controller
'taskName' => $task->name,
'start' => $task->start,
'end' => $task->end,
+ 'eventName' => $event->name,
];
Mail::to($user->email)->send(new VolunteerUnassignToTaskMail($data));
}
diff --git a/app/Mail/TaskDateUpdateMail.php b/app/Mail/TaskDateUpdateMail.php
new file mode 100644
index 0000000..6405074
--- /dev/null
+++ b/app/Mail/TaskDateUpdateMail.php
@@ -0,0 +1,64 @@
+data = $data;
+ }
+
+ /**
+ * Get the message envelope.
+ */
+ public function envelope(): Envelope
+ {
+ return new Envelope(
+ subject: 'Date de tâche modifiée - Comité des fêtes de Beaupont',
+ );
+ }
+
+ /**
+ * Get the message content definition.
+ */
+ public function content(): Content
+ {
+ return new Content(
+ view: 'mails.updateRole',
+ with: [
+ 'name' => $this->data['name'],
+ 'lastname' => $this->data['lastname'],
+ 'taskName' => $this->data['taskName'],
+ 'oldStart' => $this->data['oldStart'],
+ 'oldEnd' => $this->data['oldEnd'],
+ 'newStart' => $this->data['newStart'],
+ 'newEnd' => $this->data['newEnd'],
+ 'eventName' => $this->data['eventName'],
+ ]
+ );
+ }
+
+ /**
+ * Get the attachments for the message.
+ *
+ * @return array
+ */
+ public function attachments(): array
+ {
+ return [];
+ }
+}
diff --git a/resources/views/mails/taskDateUpdate.blade.php b/resources/views/mails/taskDateUpdate.blade.php
new file mode 100644
index 0000000..2f48e99
--- /dev/null
+++ b/resources/views/mails/taskDateUpdate.blade.php
@@ -0,0 +1,32 @@
+
+
+
+
+
+ Date de tâche modifiée
+
+
+
+
Bonjour {{ $name }} {{ $lastname }},
+
+
+ La date de la tâche {{ $taskName }} de l'événement {{ $eventName }} a été modifié par un administrateur.
+ Cette tâche avait lieu du {{ $oldStart }} au {{ $oldEnd }}. Et aura maintenant lieu du {{ $newStart }} au {{ $newEnd }}.
+
+
+
+ Si vous pensez qu’il s’agit d’une erreur ou si vous souhaitez plus d’informations,
+ merci de contacter l’équipe du Comité des fêtes de Beaupont.
+
+
+
+ À très bientôt,
+ L’équipe du Comité des fêtes de Beaupont
+
+
+
+
+ Cet email a été envoyé automatiquement, merci de ne pas y répondre.
+
+
+
From 8371f96388f8e2eeaae8033126c1adcf6fcd7a5f Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 19 Mar 2026 17:38:06 +0100
Subject: [PATCH 45/63] add event name in mail
---
app/Mail/TaskParticipationCancelledMail.php | 1 +
app/Mail/VolunteerAssignToTaskMail.php | 1 +
app/Mail/VolunteerUnassignToTaskMail.php | 1 +
resources/views/mails/taskParticipationCancelled.blade.php | 2 +-
resources/views/mails/volunteerAssignToTask.blade.php | 2 +-
resources/views/mails/volunteerUnassignToTask.blade.php | 2 +-
6 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/app/Mail/TaskParticipationCancelledMail.php b/app/Mail/TaskParticipationCancelledMail.php
index 7eeacaf..b5a390d 100644
--- a/app/Mail/TaskParticipationCancelledMail.php
+++ b/app/Mail/TaskParticipationCancelledMail.php
@@ -46,6 +46,7 @@ class TaskParticipationCancelledMail extends Mailable
'taskName' => $this->data['taskName'],
'end' => FormatDate::formatDate($this->data['end']),
'start' => FormatDate::formatDate($this->data['start']),
+ 'eventName' => $this->data['eventName'],
]
);
}
diff --git a/app/Mail/VolunteerAssignToTaskMail.php b/app/Mail/VolunteerAssignToTaskMail.php
index 99c722b..9fa1681 100644
--- a/app/Mail/VolunteerAssignToTaskMail.php
+++ b/app/Mail/VolunteerAssignToTaskMail.php
@@ -46,6 +46,7 @@ class VolunteerAssignToTaskMail extends Mailable
'taskName' => $this->data['taskName'],
'start' => FormatDate::formatDate($this->data['start']),
'end' => FormatDate::formatDate($this->data['end']),
+ 'eventName' => $this->data['eventName'],
]
);
}
diff --git a/app/Mail/VolunteerUnassignToTaskMail.php b/app/Mail/VolunteerUnassignToTaskMail.php
index 506d0c3..b4c5305 100644
--- a/app/Mail/VolunteerUnassignToTaskMail.php
+++ b/app/Mail/VolunteerUnassignToTaskMail.php
@@ -46,6 +46,7 @@ class VolunteerUnassignToTaskMail extends Mailable
'taskName' => $this->data['taskName'],
'start' => FormatDate::formatDate($this->data['start']),
'end' => FormatDate::formatDate($this->data['end']),
+ 'eventName' => $this->data['eventName'],
]
);
}
diff --git a/resources/views/mails/taskParticipationCancelled.blade.php b/resources/views/mails/taskParticipationCancelled.blade.php
index 861520c..922b087 100644
--- a/resources/views/mails/taskParticipationCancelled.blade.php
+++ b/resources/views/mails/taskParticipationCancelled.blade.php
@@ -10,7 +10,7 @@
Bonjour {{ $name }} {{ $lastname }},
- La tâche {{ $taskName }} a été supprimé par un administrateur.
+ La tâche {{ $taskName }} de l'événement {{ $eventName }} a été supprimé par un administrateur.
Vous n’y participez donc plus. Cette tâche avait lieu du {{ $start }} au {{ $end }}.
diff --git a/resources/views/mails/volunteerAssignToTask.blade.php b/resources/views/mails/volunteerAssignToTask.blade.php
index 55c4057..e084dc7 100644
--- a/resources/views/mails/volunteerAssignToTask.blade.php
+++ b/resources/views/mails/volunteerAssignToTask.blade.php
@@ -10,7 +10,7 @@
Bonjour {{ $name }} {{ $lastname }},
- Vous avez été assigné à la tâche {{ $taskName }} par un administrateur.
+ Vous avez été assigné à la tâche {{ $taskName }} de l'événément {{ $eventName }} par un administrateur.
Cette tâche aura lieu du {{ $start }} au {{ $end }}.
diff --git a/resources/views/mails/volunteerUnassignToTask.blade.php b/resources/views/mails/volunteerUnassignToTask.blade.php
index 052c68e..d97dce0 100644
--- a/resources/views/mails/volunteerUnassignToTask.blade.php
+++ b/resources/views/mails/volunteerUnassignToTask.blade.php
@@ -10,7 +10,7 @@
Bonjour {{ $name }} {{ $lastname }},
- Vous avez été désassigné de la tâche {{ $taskName }} par un administrateur.
+ Vous avez été désassigné de la tâche {{ $taskName }} de l'événement {{ $eventName }} par un administrateur.
Vous n'y participez donc plus. Cette tâche avait lieu du {{ $start }} au {{ $end }}.
From cf2a29a863929ab4bba7a74faf3671aa92983317 Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 19 Mar 2026 17:43:02 +0100
Subject: [PATCH 46/63] rename $task->title into $task->name
---
app/Http/Controllers/TasksController.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/Http/Controllers/TasksController.php b/app/Http/Controllers/TasksController.php
index e5a90d7..5caf9bd 100644
--- a/app/Http/Controllers/TasksController.php
+++ b/app/Http/Controllers/TasksController.php
@@ -99,7 +99,7 @@ class TasksController extends Controller
$task->users()->attach($id);
$notification = Notification::create([
- 'content' => "Vous avez été assigné à la tâche {$task->title} de l'événement {$task->event->name}."
+ 'content' => "Vous avez été assigné à la tâche {$task->name} de l'événement {$task->event->name}."
]);
$notification->users()->attach($user->id);
@@ -161,7 +161,7 @@ class TasksController extends Controller
if (Carbon::now()->lessThanOrEqualTo($task->end)) {
if ($participants->isNotEmpty()) {
$notification = Notification::create([
- 'content' => "La tâche '{$task->title}' pour l'événement '{$task->event->name}' a été supprimée. Vous n'y participez donc plus."
+ 'content' => "La tâche '{$task->name}' pour l'événement '{$task->event->name}' a été supprimée. Vous n'y participez donc plus."
]);
$notification->users()->attach($participants->pluck('id'));
}
@@ -215,7 +215,7 @@ class TasksController extends Controller
foreach ($participants as $user) {
$notification = Notification::create([
- 'content' => "La date de la tâche {$task->title} de l'événement {$task->event->name} à été mis à jour. Cette tâche aura maintenant lieu du {$formatedTaskStart} au {$formatedTaskEnd}."
+ 'content' => "La date de la tâche {$task->name} de l'événement {$task->event->name} à été mis à jour. Cette tâche aura maintenant lieu du {$formatedTaskStart} au {$formatedTaskEnd}."
]);
$notification->users()->attach($user->id);
broadcast(new TaskDateUpdated(
@@ -296,7 +296,7 @@ class TasksController extends Controller
if ($user && Carbon::now()->lessThanOrEqualTo($task->end)) {
$task->users()->detach($id);
$notification = Notification::create([
- 'content' => "Vous avez été désassigné de la tâche {$task->title} de l'événement {$task->event->name}."
+ 'content' => "Vous avez été désassigné de la tâche {$task->name} de l'événement {$task->event->name}."
]);
$notification->users()->attach($user->id);
broadcast(new VolunteerUnassignedFromTask(
From d627afdeaf7daada75c59237a99457bb791c5a91 Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 19 Mar 2026 17:49:41 +0100
Subject: [PATCH 47/63] add information in task date updated notification
---
app/Events/TaskDateUpdated.php | 8 +++++++-
app/Http/Controllers/TasksController.php | 5 ++++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/app/Events/TaskDateUpdated.php b/app/Events/TaskDateUpdated.php
index af928d2..9526a5b 100644
--- a/app/Events/TaskDateUpdated.php
+++ b/app/Events/TaskDateUpdated.php
@@ -15,15 +15,21 @@ class TaskDateUpdated implements ShouldBroadcastNow
use Dispatchable, InteractsWithSockets, SerializesModels;
public $task;
+ public $event;
+ public $start;
+ public $end;
protected $userId;
/**
* Create a new event instance.
*/
- public function __construct($userId, Task $task)
+ public function __construct($userId, Task $task, Event $event, $start, $end)
{
$this->userId = $userId;
$this->task = $task;
+ $this->event = $event;
+ $this->start = $start;
+ $this->end = $end;
}
/**
diff --git a/app/Http/Controllers/TasksController.php b/app/Http/Controllers/TasksController.php
index 5caf9bd..c13e117 100644
--- a/app/Http/Controllers/TasksController.php
+++ b/app/Http/Controllers/TasksController.php
@@ -215,12 +215,15 @@ class TasksController extends Controller
foreach ($participants as $user) {
$notification = Notification::create([
- 'content' => "La date de la tâche {$task->name} de l'événement {$task->event->name} à été mis à jour. Cette tâche aura maintenant lieu du {$formatedTaskStart} au {$formatedTaskEnd}."
+ 'content' => "La date de la tâche {$task->name} de l'événement {$event->name} à été mis à jour. Cette tâche aura maintenant lieu du {$formatedTaskStart} au {$formatedTaskEnd}."
]);
$notification->users()->attach($user->id);
broadcast(new TaskDateUpdated(
$user->id,
$task,
+ $event,
+ $newStart,
+ $newEnd,
));
$data = [
From b7ccc38b688cbffede31157ab3858342ed7e79eb Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 19 Mar 2026 17:51:18 +0100
Subject: [PATCH 48/63] add information in task date updated notification
---
app/Http/Controllers/TasksController.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/Http/Controllers/TasksController.php b/app/Http/Controllers/TasksController.php
index c13e117..c5b7936 100644
--- a/app/Http/Controllers/TasksController.php
+++ b/app/Http/Controllers/TasksController.php
@@ -222,8 +222,8 @@ class TasksController extends Controller
$user->id,
$task,
$event,
- $newStart,
- $newEnd,
+ FormatDate::formatDate($request["start"]),
+ FormatDate::formatDate($request["end"]),
));
$data = [
From ec76ca981a37c35a967b3711c2211c6476e1af9d Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 19 Mar 2026 18:01:55 +0100
Subject: [PATCH 49/63] add information in notifications
---
app/Http/Controllers/TasksController.php | 12 ++++++------
app/Http/Controllers/UserController.php | 5 +++--
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/app/Http/Controllers/TasksController.php b/app/Http/Controllers/TasksController.php
index c5b7936..e08bd52 100644
--- a/app/Http/Controllers/TasksController.php
+++ b/app/Http/Controllers/TasksController.php
@@ -99,14 +99,14 @@ class TasksController extends Controller
$task->users()->attach($id);
$notification = Notification::create([
- 'content' => "Vous avez été assigné à la tâche {$task->name} de l'événement {$task->event->name}."
+ 'content' => "Vous avez été assigné à la tâche {$task->name} de l'événement {$event->name}."
]);
$notification->users()->attach($user->id);
broadcast(new VolunteerAssignedToTask(
$user->id,
$task,
- $event
+ $event,
));
$data = [
@@ -161,7 +161,7 @@ class TasksController extends Controller
if (Carbon::now()->lessThanOrEqualTo($task->end)) {
if ($participants->isNotEmpty()) {
$notification = Notification::create([
- 'content' => "La tâche '{$task->name}' pour l'événement '{$task->event->name}' a été supprimée. Vous n'y participez donc plus."
+ 'content' => "La tâche '{$task->name}' pour l'événement '{$event->name}' a été supprimée. Vous n'y participez donc plus."
]);
$notification->users()->attach($participants->pluck('id'));
}
@@ -170,7 +170,7 @@ class TasksController extends Controller
broadcast(new TaskParticipationCancelled(
$user->id,
$task,
- $event
+ $event,
));
$data = [
@@ -299,13 +299,13 @@ class TasksController extends Controller
if ($user && Carbon::now()->lessThanOrEqualTo($task->end)) {
$task->users()->detach($id);
$notification = Notification::create([
- 'content' => "Vous avez été désassigné de la tâche {$task->name} de l'événement {$task->event->name}."
+ 'content' => "Vous avez été désassigné de la tâche {$task->name} de l'événement {$event->name}."
]);
$notification->users()->attach($user->id);
broadcast(new VolunteerUnassignedFromTask(
$user->id,
$task,
- $event
+ $event,
));
$data = [
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index f58ba6b..58e6772 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -12,6 +12,7 @@ use App\Mail\UpdateRoleMail;
use App\Mail\ValidateMail;
use App\Models\Notification;
use App\Models\User;
+use App\Services\GetRole;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -253,10 +254,10 @@ class UserController extends Controller
$user->role = $request['role'];
$user->save();
- $role = \App\Services\GetRole::getRole($request['role']);
+ $role = GetRole::getRole($request['role']);
$notification = Notification::create([
- 'content' => "Votre rôle à changé pour : {$role} !",
+ 'content' => "Votre rôle à changé pour : {$role}",
]);
$notification->users()->attach($user->id);
From 9fbc09017b8f613552084d6df1acfcbe05c7cce3 Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 19 Mar 2026 18:09:11 +0100
Subject: [PATCH 50/63] add $notificationId to every broadcast notification
---
app/Events/EventParticipationCancelled.php | 4 +++-
app/Events/TaskDateUpdated.php | 4 +++-
app/Events/TaskParticipationCancelled.php | 4 +++-
app/Events/UserCreated.php | 4 +++-
app/Events/VolunteerAssignedToTask.php | 4 +++-
app/Events/VolunteerRoleUpdated.php | 4 +++-
app/Events/VolunteerUnassignedFromTask.php | 4 +++-
app/Http/Controllers/EventsController.php | 3 ++-
app/Http/Controllers/TasksController.php | 4 ++++
app/Http/Controllers/UserController.php | 8 ++++++--
10 files changed, 33 insertions(+), 10 deletions(-)
diff --git a/app/Events/EventParticipationCancelled.php b/app/Events/EventParticipationCancelled.php
index 23f04f0..015ba90 100644
--- a/app/Events/EventParticipationCancelled.php
+++ b/app/Events/EventParticipationCancelled.php
@@ -16,14 +16,16 @@ class EventParticipationCancelled implements ShouldBroadcastNow
public $userId;
public $event;
+ public $notificationId;
/**
* Create a new event instance.
*/
- public function __construct($userId, Event $event)
+ public function __construct($userId, Event $event, $notificationId)
{
$this->userId = $userId;
$this->event = $event;
+ $this->notificationId = $notificationId;
}
/**
diff --git a/app/Events/TaskDateUpdated.php b/app/Events/TaskDateUpdated.php
index 9526a5b..dcf7fa1 100644
--- a/app/Events/TaskDateUpdated.php
+++ b/app/Events/TaskDateUpdated.php
@@ -18,18 +18,20 @@ class TaskDateUpdated implements ShouldBroadcastNow
public $event;
public $start;
public $end;
+ public $notificationId;
protected $userId;
/**
* Create a new event instance.
*/
- public function __construct($userId, Task $task, Event $event, $start, $end)
+ public function __construct($userId, Task $task, Event $event, $start, $end, $notificationId)
{
$this->userId = $userId;
$this->task = $task;
$this->event = $event;
$this->start = $start;
$this->end = $end;
+ $this->notificationId = $notificationId;
}
/**
diff --git a/app/Events/TaskParticipationCancelled.php b/app/Events/TaskParticipationCancelled.php
index df6ee78..698a10e 100644
--- a/app/Events/TaskParticipationCancelled.php
+++ b/app/Events/TaskParticipationCancelled.php
@@ -17,15 +17,17 @@ class TaskParticipationCancelled implements ShouldBroadcastNow
public $userId;
public $task;
public $event;
+ public $notificationId;
/**
* Create a new event instance.
*/
- public function __construct($userId, Task $task, Event $event)
+ public function __construct($userId, Task $task, Event $event, $notificationId)
{
$this->userId = $userId;
$this->task = $task;
$this->event = $event;
+ $this->notificationId = $notificationId;
}
/**
diff --git a/app/Events/UserCreated.php b/app/Events/UserCreated.php
index ead5cf3..a27ee47 100644
--- a/app/Events/UserCreated.php
+++ b/app/Events/UserCreated.php
@@ -15,13 +15,15 @@ class UserCreated implements ShouldBroadcastNow
public $user;
+ public $notificationId;
/**
* Create a new event instance.
*/
- public function __construct(User $user)
+ public function __construct(User $user, $notificationId)
{
$this->user = $user;
+ $this->notificationId = $notificationId;
}
/**
diff --git a/app/Events/VolunteerAssignedToTask.php b/app/Events/VolunteerAssignedToTask.php
index 120f17c..0b96aaf 100644
--- a/app/Events/VolunteerAssignedToTask.php
+++ b/app/Events/VolunteerAssignedToTask.php
@@ -16,16 +16,18 @@ class VolunteerAssignedToTask implements ShouldBroadcastNow
public $task;
public $event;
+ public $notificationId;
protected $userId;
/**
* Create a new event instance.
*/
- public function __construct($userId, Task $task, Event $event)
+ public function __construct($userId, Task $task, Event $event, $notificationId)
{
$this->userId = $userId;
$this->task = $task;
$this->event = $event;
+ $this->notificationId = $notificationId;
}
/**
diff --git a/app/Events/VolunteerRoleUpdated.php b/app/Events/VolunteerRoleUpdated.php
index e73bd47..690d114 100644
--- a/app/Events/VolunteerRoleUpdated.php
+++ b/app/Events/VolunteerRoleUpdated.php
@@ -15,15 +15,17 @@ class VolunteerRoleUpdated implements ShouldBroadcastNow
use Dispatchable, InteractsWithSockets, SerializesModels;
public $role;
+ public $notificationId;
protected $userId;
/**
* Create a new event instance.
*/
- public function __construct($userId, $role)
+ public function __construct($userId, $role, $notificationId)
{
$this->userId = $userId;
$this->role = $role;
+ $this->notificationId = $notificationId;
}
/**
diff --git a/app/Events/VolunteerUnassignedFromTask.php b/app/Events/VolunteerUnassignedFromTask.php
index 70c1207..14f370b 100644
--- a/app/Events/VolunteerUnassignedFromTask.php
+++ b/app/Events/VolunteerUnassignedFromTask.php
@@ -17,15 +17,17 @@ class VolunteerUnassignedFromTask implements ShouldBroadcastNow
public $userId;
public $task;
public $event;
+ public $notificationId;
/**
* Create a new event instance.
*/
- public function __construct($userId, Task $task, Event $event)
+ public function __construct($userId, Task $task, Event $event, $notificationId)
{
$this->userId = $userId;
$this->task = $task;
$this->event = $event;
+ $this->notificationId = $notificationId;
}
/**
diff --git a/app/Http/Controllers/EventsController.php b/app/Http/Controllers/EventsController.php
index 117398e..080851e 100644
--- a/app/Http/Controllers/EventsController.php
+++ b/app/Http/Controllers/EventsController.php
@@ -107,7 +107,8 @@ class EventsController extends Controller
foreach ($participants as $user) {
broadcast(new EventParticipationCancelled(
$user->id,
- $event
+ $event,
+ $notification->id,
));
$data = [
diff --git a/app/Http/Controllers/TasksController.php b/app/Http/Controllers/TasksController.php
index e08bd52..412ef0d 100644
--- a/app/Http/Controllers/TasksController.php
+++ b/app/Http/Controllers/TasksController.php
@@ -107,6 +107,7 @@ class TasksController extends Controller
$user->id,
$task,
$event,
+ $notification->id,
));
$data = [
@@ -171,6 +172,7 @@ class TasksController extends Controller
$user->id,
$task,
$event,
+ $notification->id,
));
$data = [
@@ -224,6 +226,7 @@ class TasksController extends Controller
$event,
FormatDate::formatDate($request["start"]),
FormatDate::formatDate($request["end"]),
+ $notification->id,
));
$data = [
@@ -306,6 +309,7 @@ class TasksController extends Controller
$user->id,
$task,
$event,
+ $notification->id,
));
$data = [
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index 58e6772..2622071 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -61,7 +61,10 @@ class UserController extends Controller
$notification->users()->attach(
$admins->pluck('id')->toArray()
);
- broadcast(new UserCreated($user));
+ broadcast(new UserCreated(
+ $user,
+ $notification->id,
+ ));
foreach ($admins as $admin) {
$data = [
@@ -263,7 +266,8 @@ class UserController extends Controller
broadcast(new VolunteerRoleUpdated(
$user->id,
- $role
+ $role,
+ $notification->id,
));
$data = [
From 2252ac9547866abad101a29056833ecef78f17b9 Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 19 Mar 2026 18:22:36 +0100
Subject: [PATCH 51/63] add $notificationId to every broadcast notification
---
app/Http/Controllers/EventsController.php | 2 +-
app/Http/Controllers/TasksController.php | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/app/Http/Controllers/EventsController.php b/app/Http/Controllers/EventsController.php
index 080851e..b41c2f9 100644
--- a/app/Http/Controllers/EventsController.php
+++ b/app/Http/Controllers/EventsController.php
@@ -100,7 +100,7 @@ class EventsController extends Controller
if (Carbon::now()->lessThanOrEqualTo($event->end)) {
$notification = Notification::create([
- 'content' => "L'événement '{$event->name}' a été supprimé. Vous n'y participez donc plus."
+ 'content' => "L'événement {$event->name} a été supprimé. Vous n'y participez donc plus."
]);
$notification->users()->attach($participants->pluck('id'));
diff --git a/app/Http/Controllers/TasksController.php b/app/Http/Controllers/TasksController.php
index 412ef0d..a74bf04 100644
--- a/app/Http/Controllers/TasksController.php
+++ b/app/Http/Controllers/TasksController.php
@@ -32,7 +32,7 @@ class TasksController extends Controller
try {
- $event = Event::find($request["events_id"]);
+ $event = Event::find($request["event_id"]);
$event->tasks()->create([
"name" => $request["name"],
@@ -94,9 +94,9 @@ class TasksController extends Controller
}
$user = User::find($id);
+ $task->users()->attach($id);
if($user && Carbon::now()->lessThanOrEqualTo($task->end)) {
- $task->users()->attach($id);
$notification = Notification::create([
'content' => "Vous avez été assigné à la tâche {$task->name} de l'événement {$event->name}."
@@ -162,7 +162,7 @@ class TasksController extends Controller
if (Carbon::now()->lessThanOrEqualTo($task->end)) {
if ($participants->isNotEmpty()) {
$notification = Notification::create([
- 'content' => "La tâche '{$task->name}' pour l'événement '{$event->name}' a été supprimée. Vous n'y participez donc plus."
+ 'content' => "La tâche {$task->name} pour l'événement {$event->name} a été supprimée. Vous n'y participez donc plus."
]);
$notification->users()->attach($participants->pluck('id'));
}
@@ -298,9 +298,9 @@ class TasksController extends Controller
}
$user = User::find($id);
+ $task->users()->detach($id);
if ($user && Carbon::now()->lessThanOrEqualTo($task->end)) {
- $task->users()->detach($id);
$notification = Notification::create([
'content' => "Vous avez été désassigné de la tâche {$task->name} de l'événement {$event->name}."
]);
From 1f6f280958a2946817fd6b303234cd5f35f3512b Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 26 Mar 2026 09:03:51 +0100
Subject: [PATCH 52/63] add web_notifications and email_notifications attributs
to User migration and model
---
app/Models/User.php | 4 +++-
database/migrations/2025_10_13_215246_create_users_table.php | 2 ++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/app/Models/User.php b/app/Models/User.php
index cbbb472..43598cb 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -26,7 +26,9 @@ class User extends Authenticatable
'validate',
'role',
'verified_at',
- 'profile_photo_path'
+ 'profile_photo_path',
+ 'email_notifications',
+ 'web_notifiactions'
];
/**
diff --git a/database/migrations/2025_10_13_215246_create_users_table.php b/database/migrations/2025_10_13_215246_create_users_table.php
index 509e0ae..da09a2e 100644
--- a/database/migrations/2025_10_13_215246_create_users_table.php
+++ b/database/migrations/2025_10_13_215246_create_users_table.php
@@ -21,6 +21,8 @@ return new class extends Migration
$table->integer('validate');
$table->integer('role')->nullable();
$table->dateTime('verified_at')->nullable();
+ $table->integer('email_notifications');
+ $table->integer('web_notifiactions');
$table->timestamps();
});
}
From 32607f32d8376ed971d4f824f5d077d8954073e6 Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 26 Mar 2026 09:05:40 +0100
Subject: [PATCH 53/63] add web_notifications and email_notifications value to
admin user in seeders
---
database/seeders/DevSeeder.php | 4 +++-
database/seeders/ProdSeeder.php | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/database/seeders/DevSeeder.php b/database/seeders/DevSeeder.php
index 06b033f..848f6af 100644
--- a/database/seeders/DevSeeder.php
+++ b/database/seeders/DevSeeder.php
@@ -25,7 +25,9 @@ class DevSeeder extends Seeder
'password' => bcrypt(config('app.admin_password')),
'phone' => config('app.admin_phone'),
'role' => 1,
- 'validate' => 1
+ 'validate' => 1,
+ 'web_notifiactions' => 1,
+ 'email_notifications' => 1,
]
);
diff --git a/database/seeders/ProdSeeder.php b/database/seeders/ProdSeeder.php
index 99e55ae..0559dbf 100644
--- a/database/seeders/ProdSeeder.php
+++ b/database/seeders/ProdSeeder.php
@@ -23,7 +23,9 @@ class ProdSeeder extends Seeder
'password' => bcrypt(config('app.admin_password')),
'phone' => config('app.admin_phone'),
'role' => 1,
- 'validate' => 1
+ 'validate' => 1,
+ 'web_notifiactions' => 1,
+ 'email_notifications' => 1,
]
);
From c1d7f5cd815655724d178004cd6b152d30a0c8f0 Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 26 Mar 2026 09:06:13 +0100
Subject: [PATCH 54/63] add web_notifications and email_notifications value to
the created user in create method of user controller
---
app/Http/Controllers/UserController.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index 2622071..64f82a9 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -51,6 +51,8 @@ class UserController extends Controller
"lastname" => $request["lastname"],
"validate" => 0,
"phone" => $phone->formatInternational(),
+ "web_notifiactions" => 1,
+ "email_notifications" => 1,
]);
From 712bdd02cdd58c03c624ddab4a5b7243d50995b0 Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 26 Mar 2026 09:13:57 +0100
Subject: [PATCH 55/63] create toggleEmailNotifications method in user
controller
---
app/Http/Controllers/UserController.php | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index 64f82a9..5615119 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -350,4 +350,18 @@ class UserController extends Controller
return response()->json(['message' => "Server error"], 500);
}
}
+
+ public function toggleEmailNotifications(Request $request, int $id): JsonResponse {
+ try {
+ $user = User::findOrFail($id);
+ $user->email_notifications = !$user->email_notifications ? 0 : 1;
+ $user->save();
+
+ return response()->json($user);
+ }catch(\Exception $e){
+ Log::info($e->getMessage());
+ return response()->json(['message' => "Server error"], 500);
+ }
+ }
}
+
From 78645e3cb050a12fff1380e45436e8b349f24c93 Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 26 Mar 2026 09:14:17 +0100
Subject: [PATCH 56/63] create /users/{id}/email-notifications route in user
route
---
routes/users.php | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/routes/users.php b/routes/users.php
index eeb2ac0..de5c627 100644
--- a/routes/users.php
+++ b/routes/users.php
@@ -38,3 +38,8 @@ Route::middleware(['web', 'auth:sanctum'])->get('/users/search', [SearchControll
Route::middleware(['web', 'auth:sanctum'])->get('/users/invalid', [UserController::class, "getInvalidUsers"]);
+Route::middleware(['web', 'auth:sanctum'])->patch('/users/{id}/email-notifications', [UserController::class, "toggleEmailNotifications"])
+ ->whereNumber('id');
+
+
+
From fa58184f2131f9500c99c422adc1032cd596ba47 Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 26 Mar 2026 09:14:55 +0100
Subject: [PATCH 57/63] create toggleWebNotifications method in user controller
---
app/Http/Controllers/UserController.php | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index 5615119..6e5459e 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -363,5 +363,18 @@ class UserController extends Controller
return response()->json(['message' => "Server error"], 500);
}
}
+
+ public function togglWebNotifications(Request $request, int $id): JsonResponse {
+ try {
+ $user = User::findOrFail($id);
+ $user->web_notifications = !$user->web_notifications ? 0 : 1;
+ $user->save();
+
+ return response()->json($user);
+ }catch(\Exception $e){
+ Log::info($e->getMessage());
+ return response()->json(['message' => "Server error"], 500);
+ }
+ }
}
From fdc79baf26101298489eb06e9011ca9bb47ea242 Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 26 Mar 2026 09:15:21 +0100
Subject: [PATCH 58/63] create /users/{id}/web-notifications route in user
route
---
routes/users.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/routes/users.php b/routes/users.php
index de5c627..261389a 100644
--- a/routes/users.php
+++ b/routes/users.php
@@ -41,5 +41,7 @@ Route::middleware(['web', 'auth:sanctum'])->get('/users/invalid', [UserControlle
Route::middleware(['web', 'auth:sanctum'])->patch('/users/{id}/email-notifications', [UserController::class, "toggleEmailNotifications"])
->whereNumber('id');
+Route::middleware(['web', 'auth:sanctum'])->patch('/users/{id}/web-notifications', [UserController::class, "toggleWebNotifications"])
+ ->whereNumber('id');
From 368465b8f347170d090b99d1d85da3d030d01ff6 Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 26 Mar 2026 09:48:36 +0100
Subject: [PATCH 59/63] add default value to email_notifications and
web_notifications
---
database/migrations/2025_10_13_215246_create_users_table.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/database/migrations/2025_10_13_215246_create_users_table.php b/database/migrations/2025_10_13_215246_create_users_table.php
index da09a2e..36889f2 100644
--- a/database/migrations/2025_10_13_215246_create_users_table.php
+++ b/database/migrations/2025_10_13_215246_create_users_table.php
@@ -21,8 +21,8 @@ return new class extends Migration
$table->integer('validate');
$table->integer('role')->nullable();
$table->dateTime('verified_at')->nullable();
- $table->integer('email_notifications');
- $table->integer('web_notifiactions');
+ $table->integer('email_notifications')->default(1);
+ $table->integer('web_notifiactions')->default(1);
$table->timestamps();
});
}
From 3528df05718f2465c3db21909af77fe91aa40c3c Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 26 Mar 2026 09:54:32 +0100
Subject: [PATCH 60/63] fix toggleWebNotifications method name
---
app/Http/Controllers/UserController.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index 6e5459e..f65d193 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -364,7 +364,7 @@ class UserController extends Controller
}
}
- public function togglWebNotifications(Request $request, int $id): JsonResponse {
+ public function toggleWebNotifications(Request $request, int $id): JsonResponse {
try {
$user = User::findOrFail($id);
$user->web_notifications = !$user->web_notifications ? 0 : 1;
From c73f4bd35b109304d8511ae008322c6a13b22874 Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 26 Mar 2026 09:57:47 +0100
Subject: [PATCH 61/63] correct wrong ternary condition
---
app/Http/Controllers/UserController.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index f65d193..f3d7ede 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -354,7 +354,7 @@ class UserController extends Controller
public function toggleEmailNotifications(Request $request, int $id): JsonResponse {
try {
$user = User::findOrFail($id);
- $user->email_notifications = !$user->email_notifications ? 0 : 1;
+ $user->email_notifications = $user->email_notifications ? 0 : 1;
$user->save();
return response()->json($user);
@@ -367,7 +367,7 @@ class UserController extends Controller
public function toggleWebNotifications(Request $request, int $id): JsonResponse {
try {
$user = User::findOrFail($id);
- $user->web_notifications = !$user->web_notifications ? 0 : 1;
+ $user->web_notifications = $user->web_notifications ? 0 : 1;
$user->save();
return response()->json($user);
From 83ec6c9a2a7fe6b28e295e7c04b783880fd990a7 Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 26 Mar 2026 10:19:18 +0100
Subject: [PATCH 62/63] correct wrong spelling of web_notifications
---
app/Http/Controllers/UserController.php | 2 +-
app/Models/User.php | 2 +-
app/Services/UserService.php | 2 ++
database/migrations/2025_10_13_215246_create_users_table.php | 2 +-
database/seeders/DevSeeder.php | 2 +-
database/seeders/ProdSeeder.php | 2 +-
6 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index f3d7ede..f8fb25e 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -51,7 +51,7 @@ class UserController extends Controller
"lastname" => $request["lastname"],
"validate" => 0,
"phone" => $phone->formatInternational(),
- "web_notifiactions" => 1,
+ "web_notifications" => 1,
"email_notifications" => 1,
]);
diff --git a/app/Models/User.php b/app/Models/User.php
index 43598cb..0df9fd2 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -28,7 +28,7 @@ class User extends Authenticatable
'verified_at',
'profile_photo_path',
'email_notifications',
- 'web_notifiactions'
+ 'web_notifications'
];
/**
diff --git a/app/Services/UserService.php b/app/Services/UserService.php
index 01df1da..2942786 100644
--- a/app/Services/UserService.php
+++ b/app/Services/UserService.php
@@ -24,6 +24,8 @@ class UserService
"validate" => $user->validate,
"tasks" => $user->tasks,
"profile_photo_path" => $user->profile_photo_path,
+ "email_notifications" => $user->email_notifications,
+ "web_notifications" => $user->web_notifications,
];
}
}
diff --git a/database/migrations/2025_10_13_215246_create_users_table.php b/database/migrations/2025_10_13_215246_create_users_table.php
index 36889f2..b989881 100644
--- a/database/migrations/2025_10_13_215246_create_users_table.php
+++ b/database/migrations/2025_10_13_215246_create_users_table.php
@@ -22,7 +22,7 @@ return new class extends Migration
$table->integer('role')->nullable();
$table->dateTime('verified_at')->nullable();
$table->integer('email_notifications')->default(1);
- $table->integer('web_notifiactions')->default(1);
+ $table->integer('web_notifications')->default(1);
$table->timestamps();
});
}
diff --git a/database/seeders/DevSeeder.php b/database/seeders/DevSeeder.php
index 848f6af..0be9f81 100644
--- a/database/seeders/DevSeeder.php
+++ b/database/seeders/DevSeeder.php
@@ -26,7 +26,7 @@ class DevSeeder extends Seeder
'phone' => config('app.admin_phone'),
'role' => 1,
'validate' => 1,
- 'web_notifiactions' => 1,
+ 'web_notifications' => 1,
'email_notifications' => 1,
]
);
diff --git a/database/seeders/ProdSeeder.php b/database/seeders/ProdSeeder.php
index 0559dbf..5ee8d00 100644
--- a/database/seeders/ProdSeeder.php
+++ b/database/seeders/ProdSeeder.php
@@ -24,7 +24,7 @@ class ProdSeeder extends Seeder
'phone' => config('app.admin_phone'),
'role' => 1,
'validate' => 1,
- 'web_notifiactions' => 1,
+ 'web_notifications' => 1,
'email_notifications' => 1,
]
);
From 1d9c6726b39c09237dd69c2ca2af36e4c85b1e7c Mon Sep 17 00:00:00 2001
From: Giovanni-Josserand
Date: Thu, 26 Mar 2026 10:29:51 +0100
Subject: [PATCH 63/63] check if user accept notifications
---
app/Http/Controllers/EventsController.php | 45 +++--
app/Http/Controllers/TasksController.php | 202 ++++++++++++----------
app/Http/Controllers/UserController.php | 144 ++++++++-------
3 files changed, 208 insertions(+), 183 deletions(-)
diff --git a/app/Http/Controllers/EventsController.php b/app/Http/Controllers/EventsController.php
index b41c2f9..4ac3e5a 100644
--- a/app/Http/Controllers/EventsController.php
+++ b/app/Http/Controllers/EventsController.php
@@ -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));
+ }
}
}
diff --git a/app/Http/Controllers/TasksController.php b/app/Http/Controllers/TasksController.php
index a74bf04..9c655c4 100644
--- a/app/Http/Controllers/TasksController.php
+++ b/app/Http/Controllers/TasksController.php
@@ -35,15 +35,14 @@ class TasksController extends Controller
$event = Event::find($request["event_id"]);
$event->tasks()->create([
- "name" => $request["name"],
- "description" => $request["description"],
- "start" => $request["start"],
- "end" => $request["end"],
- "location" => $request["location"],
- "max_participants" => $request["max_participants"],
+ "name" => $request["name"],
+ "description" => $request["description"],
+ "start" => $request["start"],
+ "end" => $request["end"],
+ "location" => $request["location"],
+ "max_participants" => $request["max_participants"],
]);
-
return response()->json(['message' => "Task created"], 200);
} catch(\Exception $e) {
@@ -98,27 +97,31 @@ class TasksController extends Controller
if($user && Carbon::now()->lessThanOrEqualTo($task->end)) {
- $notification = Notification::create([
- 'content' => "Vous avez été assigné à la tâche {$task->name} de l'événement {$event->name}."
- ]);
- $notification->users()->attach($user->id);
+ if ($user->web_notifications) {
+ $notification = Notification::create([
+ 'content' => "Vous avez été assigné à la tâche {$task->name} de l'événement {$event->name}."
+ ]);
+ $notification->users()->attach($user->id);
- broadcast(new VolunteerAssignedToTask(
- $user->id,
- $task,
- $event,
- $notification->id,
- ));
+ broadcast(new VolunteerAssignedToTask(
+ $user->id,
+ $task,
+ $event,
+ $notification->id,
+ ));
+ }
- $data = [
- 'name' => $user->name,
- 'lastname' => $user->lastname,
- 'taskName' => $task->name,
- 'start' => $task->start,
- 'end' => $task->end,
- 'eventName' => $event->name,
- ];
- Mail::to($user->email)->send(new VolunteerAssignToTaskMail($data));
+ if ($user->email_notifications) {
+ $data = [
+ 'name' => $user->name,
+ 'lastname' => $user->lastname,
+ 'taskName' => $task->name,
+ 'start' => $task->start,
+ 'end' => $task->end,
+ 'eventName' => $event->name,
+ ];
+ Mail::to($user->email)->send(new VolunteerAssignToTaskMail($data));
+ }
}
return response()->json(['message' => "Task assigned"], 200);
@@ -141,7 +144,6 @@ class TasksController extends Controller
Log::info($e->getMessage());
return response()->json(['message' => "Server error"], 500);
}
-
}
public function deleteTask(Request $request, int $id): JsonResponse {
@@ -161,29 +163,37 @@ class TasksController extends Controller
if (Carbon::now()->lessThanOrEqualTo($task->end)) {
if ($participants->isNotEmpty()) {
- $notification = Notification::create([
- 'content' => "La tâche {$task->name} pour l'événement {$event->name} a été supprimée. Vous n'y participez donc plus."
- ]);
- $notification->users()->attach($participants->pluck('id'));
- }
+ $webParticipants = $participants->filter(fn($user) => $user->web_notifications);
- foreach ($participants as $user) {
- broadcast(new TaskParticipationCancelled(
- $user->id,
- $task,
- $event,
- $notification->id,
- ));
+ if ($webParticipants->isNotEmpty()) {
+ $notification = Notification::create([
+ 'content' => "La tâche {$task->name} pour l'événement {$event->name} a été supprimée. Vous n'y participez donc plus."
+ ]);
+ $notification->users()->attach($webParticipants->pluck('id'));
- $data = [
- 'name' => $user->name,
- 'lastname' => $user->lastname,
- 'taskName' => $task->name,
- 'start' => $event->start,
- 'end' => $task->end,
- 'eventName' => $event->name,
- ];
- Mail::to($user->email)->send(new TaskParticipationCancelledMail($data));
+ foreach ($webParticipants as $user) {
+ broadcast(new TaskParticipationCancelled(
+ $user->id,
+ $task,
+ $event,
+ $notification->id,
+ ));
+ }
+ }
+
+ foreach ($participants as $user) {
+ if ($user->email_notifications) {
+ $data = [
+ 'name' => $user->name,
+ 'lastname' => $user->lastname,
+ 'taskName' => $task->name,
+ 'start' => $event->start,
+ 'end' => $task->end,
+ 'eventName' => $event->name,
+ ];
+ Mail::to($user->email)->send(new TaskParticipationCancelledMail($data));
+ }
+ }
}
}
@@ -206,7 +216,7 @@ class TasksController extends Controller
try {
$task = Task::find($id);
if((
- $task->start !== $request["start"] || $task->end !== $request["end"]
+ $task->start !== $request["start"] || $task->end !== $request["end"]
) &&
Carbon::now()->lessThanOrEqualTo($task->end)
){
@@ -216,30 +226,35 @@ class TasksController extends Controller
$event = Event::find($task->events_id);
foreach ($participants as $user) {
- $notification = Notification::create([
- 'content' => "La date de la tâche {$task->name} de l'événement {$event->name} à été mis à jour. Cette tâche aura maintenant lieu du {$formatedTaskStart} au {$formatedTaskEnd}."
- ]);
- $notification->users()->attach($user->id);
- broadcast(new TaskDateUpdated(
- $user->id,
- $task,
- $event,
- FormatDate::formatDate($request["start"]),
- FormatDate::formatDate($request["end"]),
- $notification->id,
- ));
+ if ($user->web_notifications) {
+ $notification = Notification::create([
+ 'content' => "La date de la tâche {$task->name} de l'événement {$event->name} à été mis à jour. Cette tâche aura maintenant lieu du {$formatedTaskStart} au {$formatedTaskEnd}."
+ ]);
+ $notification->users()->attach($user->id);
- $data = [
- 'name' => $user->name,
- 'lastname' => $user->lastname,
- 'taskName' => $task->name,
- 'oldStart' => $formatedTaskStart,
- 'oldEnd' => $formatedTaskEnd,
- 'newStart' => $request["start"],
- 'newEnd' => $request["end"],
- 'eventName' => $event->name,
- ];
- Mail::to($user->email)->send(new TaskDateUpdateMail($data));
+ broadcast(new TaskDateUpdated(
+ $user->id,
+ $task,
+ $event,
+ FormatDate::formatDate($request["start"]),
+ FormatDate::formatDate($request["end"]),
+ $notification->id,
+ ));
+ }
+
+ if ($user->email_notifications) {
+ $data = [
+ 'name' => $user->name,
+ 'lastname' => $user->lastname,
+ 'taskName' => $task->name,
+ 'oldStart' => $formatedTaskStart,
+ 'oldEnd' => $formatedTaskEnd,
+ 'newStart' => $request["start"],
+ 'newEnd' => $request["end"],
+ 'eventName' => $event->name,
+ ];
+ Mail::to($user->email)->send(new TaskDateUpdateMail($data));
+ }
}
}
@@ -301,26 +316,31 @@ class TasksController extends Controller
$task->users()->detach($id);
if ($user && Carbon::now()->lessThanOrEqualTo($task->end)) {
- $notification = Notification::create([
- 'content' => "Vous avez été désassigné de la tâche {$task->name} de l'événement {$event->name}."
- ]);
- $notification->users()->attach($user->id);
- broadcast(new VolunteerUnassignedFromTask(
- $user->id,
- $task,
- $event,
- $notification->id,
- ));
+ if ($user->web_notifications) {
+ $notification = Notification::create([
+ 'content' => "Vous avez été désassigné de la tâche {$task->name} de l'événement {$event->name}."
+ ]);
+ $notification->users()->attach($user->id);
- $data = [
- 'name' => $user->name,
- 'lastname' => $user->lastname,
- 'taskName' => $task->name,
- 'start' => $task->start,
- 'end' => $task->end,
- 'eventName' => $event->name,
- ];
- Mail::to($user->email)->send(new VolunteerUnassignToTaskMail($data));
+ broadcast(new VolunteerUnassignedFromTask(
+ $user->id,
+ $task,
+ $event,
+ $notification->id,
+ ));
+ }
+
+ if ($user->email_notifications) {
+ $data = [
+ 'name' => $user->name,
+ 'lastname' => $user->lastname,
+ 'taskName' => $task->name,
+ 'start' => $task->start,
+ 'end' => $task->end,
+ 'eventName' => $event->name,
+ ];
+ Mail::to($user->email)->send(new VolunteerUnassignToTaskMail($data));
+ }
}
return response()->json(['message' => "User unassigned successfully"], 200);
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index f8fb25e..d19db18 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -55,27 +55,29 @@ class UserController extends Controller
"email_notifications" => 1,
]);
-
$notification = Notification::create([
'content' => "Nouvelle demande d'inscription : {$user->name} {$user->lastname}"
]);
$admins = User::whereIn('role', [1, 2])->get();
- $notification->users()->attach(
- $admins->pluck('id')->toArray()
- );
+
+ $webAdmins = $admins->filter(fn($admin) => $admin->web_notifications);
+ $notification->users()->attach($webAdmins->pluck('id')->toArray());
+
broadcast(new UserCreated(
$user,
$notification->id,
));
foreach ($admins as $admin) {
- $data = [
- 'adminName' => $admin->name,
- 'adminLastname' => $admin->lastname,
- 'userName' => $user->name,
- 'userLastname' => $user->lastname,
- ];
- Mail::to($admin->email)->send(new RegisterMail($data));
+ if ($admin->email_notifications) {
+ $data = [
+ 'adminName' => $admin->name,
+ 'adminLastname' => $admin->lastname,
+ 'userName' => $user->name,
+ 'userLastname' => $user->lastname,
+ ];
+ Mail::to($admin->email)->send(new RegisterMail($data));
+ }
}
return response()->json(['message' => 'User created successfully']);
@@ -104,14 +106,17 @@ class UserController extends Controller
"validate" => 1,
"role" => 3,
"phone" => $phone->formatInternational(),
+ "web_notifications" => 1,
+ "email_notifications" => 1,
]);
- $data = [
- 'name' => $user->name,
- 'lastname' => $user->lastname,
- ];
- Mail::to($user->email)->send(new CreateUserByAdminMail($data));
-
+ if ($user->email_notifications) {
+ $data = [
+ 'name' => $user->name,
+ 'lastname' => $user->lastname,
+ ];
+ Mail::to($user->email)->send(new CreateUserByAdminMail($data));
+ }
return response()->json([
'message' => 'User created successfully',
@@ -123,11 +128,13 @@ class UserController extends Controller
try {
$user = User::find($request->user()->id);
- $data = [
- 'name' => $user->name,
- 'lastname' => $user->lastname,
- ];
- Mail::to($user->email)->send(new DeleteAccountMail($data));
+ if ($user->email_notifications) {
+ $data = [
+ 'name' => $user->name,
+ 'lastname' => $user->lastname,
+ ];
+ Mail::to($user->email)->send(new DeleteAccountMail($data));
+ }
$user->delete();
return response()->json(['message' => 'User deleted successfully']);
@@ -138,7 +145,6 @@ class UserController extends Controller
}
public function getUser(Request $request, int $id): JsonResponse {
-
try {
return response()->json(UserService::getData($id));
} catch (ModelNotFoundException $e) {
@@ -147,7 +153,6 @@ class UserController extends Controller
Log::info($e->getMessage());
return response()->json(['message' => "Server error"], 500);
}
-
}
public function deleteById(Request $request, int $id): JsonResponse {
@@ -159,11 +164,13 @@ class UserController extends Controller
try {
$user = User::find($id);
- $data = [
- 'name' => $user->name,
- 'lastname' => $user->lastname,
- ];
- Mail::to($user->email)->send(new DeleteAccountMail($data));
+ if ($user->email_notifications) {
+ $data = [
+ 'name' => $user->name,
+ 'lastname' => $user->lastname,
+ ];
+ Mail::to($user->email)->send(new DeleteAccountMail($data));
+ }
$user->delete();
return response()->json(['message' => 'User deleted successfully']);
@@ -183,11 +190,13 @@ class UserController extends Controller
try {
$userToDeactivate->update(['validate' => 0]);
- $data = [
- 'name' => $userToDeactivate->name,
- 'lastname' => $userToDeactivate->lastname,
- ];
- Mail::to($userToDeactivate->email)->send(new DeactivateAccountMail($data));
+ if ($userToDeactivate->email_notifications) {
+ $data = [
+ 'name' => $userToDeactivate->name,
+ 'lastname' => $userToDeactivate->lastname,
+ ];
+ Mail::to($userToDeactivate->email)->send(new DeactivateAccountMail($data));
+ }
return response()->json(['message' => 'User deactivated successfully']);
} catch (ModelNotFoundException $e) {
@@ -196,13 +205,10 @@ class UserController extends Controller
Log::info($e->getMessage());
return response()->json(['message' => "Server error"], 500);
}
-
}
public function update(Request $request): JsonResponse {
-
try {
-
$phone = new PhoneNumber($request["phone"], 'FR');
$user = User::find($request->user()->id);
@@ -212,12 +218,10 @@ class UserController extends Controller
$user->save();
return response()->json(['message' => 'User updated successfully']);
-
} catch(\Exception $e) {
Log::info($e->getMessage());
return response()->json(['message' => "Server error"], 500);
}
-
}
public function validate(Request $request, int $id): JsonResponse {
@@ -234,14 +238,15 @@ class UserController extends Controller
$user->verified_at = now();
$user->save();
- $data = [
- 'name' => $user->name,
- 'lastname' => $user->lastname,
- ];
- Mail::to($user->email)->send(new ValidateMail($data));
+ if ($user->email_notifications) {
+ $data = [
+ 'name' => $user->name,
+ 'lastname' => $user->lastname,
+ ];
+ Mail::to($user->email)->send(new ValidateMail($data));
+ }
return response()->json(['message' => 'User validated successfully']);
-
} catch(\Exception $e) {
Log::info($e->getMessage());
return response()->json(['message' => "Server error"], 500);
@@ -261,24 +266,27 @@ class UserController extends Controller
$role = GetRole::getRole($request['role']);
- $notification = Notification::create([
- 'content' => "Votre rôle à changé pour : {$role}",
- ]);
- $notification->users()->attach($user->id);
+ if ($user->web_notifications) {
+ $notification = Notification::create([
+ 'content' => "Votre rôle à changé pour : {$role}",
+ ]);
+ $notification->users()->attach($user->id);
- broadcast(new VolunteerRoleUpdated(
- $user->id,
- $role,
- $notification->id,
- ));
-
- $data = [
- 'name' => $user->name,
- 'lastname' => $user->lastname,
- 'role' => $role,
- ];
- Mail::to($user->email)->send(new UpdateRoleMail($data));
+ broadcast(new VolunteerRoleUpdated(
+ $user->id,
+ $role,
+ $notification->id,
+ ));
+ }
+ if ($user->email_notifications) {
+ $data = [
+ 'name' => $user->name,
+ 'lastname' => $user->lastname,
+ 'role' => $role,
+ ];
+ Mail::to($user->email)->send(new UpdateRoleMail($data));
+ }
return response()->json(['message' => 'User role added successfully']);
} catch(\Exception $e) {
@@ -288,16 +296,12 @@ class UserController extends Controller
}
public function getUsers(Request $request): JsonResponse {
-
try {
-
$users = User::where('validate', 1)
->orderBy('verified_at', 'desc')
->pluck('id');
return response()->json($users);
-
-
} catch(\Exception $e) {
Log::info($e->getMessage());
return response()->json(['message' => "Server error"], 500);
@@ -305,7 +309,6 @@ class UserController extends Controller
}
public function getUserTasks(Request $request): JsonResponse {
-
try {
return response()->json(['data' => $request->user()->tasks]);
} catch (\Exception $e) {
@@ -315,7 +318,6 @@ class UserController extends Controller
}
public function getUserByIdTasks(Request $request, int $id): JsonResponse {
-
try {
return response()->json(['data' => User::find($id)->tasks]);
} catch (\Exception $e) {
@@ -325,7 +327,6 @@ class UserController extends Controller
}
public function getUserTaskById(Request $request, int $idTask): JsonResponse {
-
try {
return response()->json(['data' => $request->user()->tasks->find($idTask)]);
} catch (\Exception $e) {
@@ -340,11 +341,9 @@ class UserController extends Controller
}
try {
-
$users = User::where('validate', 0)->pluck('id');
return response()->json($users);
-
} catch (\Exception $e) {
Log::info($e->getMessage());
return response()->json(['message' => "Server error"], 500);
@@ -358,7 +357,7 @@ class UserController extends Controller
$user->save();
return response()->json($user);
- }catch(\Exception $e){
+ } catch(\Exception $e){
Log::info($e->getMessage());
return response()->json(['message' => "Server error"], 500);
}
@@ -371,10 +370,9 @@ class UserController extends Controller
$user->save();
return response()->json($user);
- }catch(\Exception $e){
+ } catch(\Exception $e){
Log::info($e->getMessage());
return response()->json(['message' => "Server error"], 500);
}
}
}
-