From 962fc3fcef95ef86e68ae030a8ddb432796e2b8f Mon Sep 17 00:00:00 2001 From: mathias Date: Mon, 20 Nov 2023 14:23:20 +0100 Subject: [PATCH] ajout route all pour les villes --- backend-laravel/app/Http/Controllers/VilleController.php | 8 ++++++++ backend-laravel/routes/api.php | 1 + 2 files changed, 9 insertions(+) diff --git a/backend-laravel/app/Http/Controllers/VilleController.php b/backend-laravel/app/Http/Controllers/VilleController.php index 2570123..22072b5 100644 --- a/backend-laravel/app/Http/Controllers/VilleController.php +++ b/backend-laravel/app/Http/Controllers/VilleController.php @@ -5,6 +5,7 @@ use Illuminate\Http\Request; use App\Models\Cycle; +use App\Models\Ville; class VilleController extends Controller { @@ -44,6 +45,13 @@ public function today() public function all() { + $villes = Ville::all(); + if(!$villes) + { + return response()->json(['error' => 'Villes not found'], 404); + } + + return response()->json($villes); } } diff --git a/backend-laravel/routes/api.php b/backend-laravel/routes/api.php index 47a0fae..2212772 100644 --- a/backend-laravel/routes/api.php +++ b/backend-laravel/routes/api.php @@ -21,3 +21,4 @@ }); Route::get('/ville/today', [VilleController::class, 'today']); +Route::get('/villes', [VilleController::class, 'all']);