correct some issues
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user