correct some issues

This commit is contained in:
2026-01-11 20:10:39 +01:00
parent ab1df4d692
commit c3122072da
10 changed files with 39 additions and 25 deletions
+6 -1
View File
@@ -70,7 +70,7 @@ class TasksController extends Controller
try {
$task = Task::find($request["task_id"]);
$task = Task::with('event')->find($request["task_id"]);
if ($task->users()->where('user_id', $id)->exists()) {
return response()->json(["message" => "User already assigned to this task"], 400);
@@ -209,6 +209,11 @@ class TasksController extends Controller
return response()->json(["message" => "Task not found"], 404);
}
if (!$task->event) {
Log::error("Relation 'event' manquante pour la tâche ID: " . $task->id);
return response()->json(["message" => "Task is missing its parent event"], 422);
}
$isAssigned = $task->users()->where('user_id', $id)->exists();
if (!$isAssigned) {
return response()->json(["message" => "User is not assigned to this task"], 400);