create a mail when a user is assigned to a task by an administrator

This commit is contained in:
2026-03-18 11:48:54 +01:00
parent 0c04694c34
commit 2921cbdcbd
4 changed files with 104 additions and 7 deletions
+10 -6
View File
@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use App\Events\TaskParticipationCancelled;
use App\Events\VolunteerAssignedToTask;
use App\Events\VolunteerUnassignedFromTask;
use App\Mail\VolunteerAssignToTaskMail;
use App\Models\Events;
use App\Models\Task;
use App\Models\User;
@@ -96,6 +97,15 @@ class TasksController extends Controller
$task,
$event
));
$data = [
'name' => $user->name,
'lastname' => $user->lastname,
'taskName' => $task->name,
'start' => $task->start,
'end' => $task->end,
];
Mail::to($user->email)->send(new VolunteerAssignToTaskMail($data));
}
return response()->json(['message' => "Task assigned"], 200);
@@ -186,10 +196,6 @@ class TasksController extends Controller
}
}
public function unassignSelf(Request $request): JsonResponse {
try {
$task = Task::find($request["task_id"]);
@@ -209,8 +215,6 @@ class TasksController extends Controller
}
}
public function unassignUser(Request $request, int $id): JsonResponse {
if(Gate::denies('unassignOther', Task::class)) {