feat: unparticipate hunt
This commit is contained in:
parent
eb471b5ded
commit
9ddfb7622a
|
|
@ -108,6 +108,20 @@ class HuntsController extends Controller
|
||||||
return response()->json(['message' => 'Participation started'], 201);
|
return response()->json(['message' => 'Participation started'], 201);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function unparticipate(Request $request, $id)
|
||||||
|
{
|
||||||
|
$hunt = Hunts::findOrFail($id);
|
||||||
|
$user = $request->user();
|
||||||
|
|
||||||
|
if (!$user->participations()->where('hunt_id', $hunt->id)->exists()) {
|
||||||
|
return response()->json(['message' => 'Not participating'], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$hunt->participants()->detach($user->id);
|
||||||
|
|
||||||
|
return response()->json(['message' => 'Participation stopped'], 200);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the specified resource in storage.
|
* Update the specified resource in storage.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ Route::middleware('auth:sanctum')->group(function (): void {
|
||||||
Route::get('users/{user}', [UsersController::class, 'show']);
|
Route::get('users/{user}', [UsersController::class, 'show']);
|
||||||
Route::post('users/{user}/avatar', [UsersController::class, 'updateAvatar']);
|
Route::post('users/{user}/avatar', [UsersController::class, 'updateAvatar']);
|
||||||
Route::post('hunts/{hunt}/participate', [HuntsController::class, 'participate']);
|
Route::post('hunts/{hunt}/participate', [HuntsController::class, 'participate']);
|
||||||
|
Route::delete('hunts/{hunt}/participate', [HuntsController::class, 'unparticipate']);
|
||||||
Route::get('auth/me', [AuthController::class, 'me']);
|
Route::get('auth/me', [AuthController::class, 'me']);
|
||||||
Route::post('auth/logout', [AuthController::class, 'logout']);
|
Route::post('auth/logout', [AuthController::class, 'logout']);
|
||||||
});
|
});
|
||||||
Loading…
Reference in New Issue