Skip to content

Commit

Permalink
ajout route all pour les villes
Browse files Browse the repository at this point in the history
  • Loading branch information
nicomaht committed Nov 20, 2023
1 parent 2b4fa93 commit 962fc3f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions backend-laravel/app/Http/Controllers/VilleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Http\Request;

use App\Models\Cycle;
use App\Models\Ville;

class VilleController extends Controller
{
Expand Down Expand Up @@ -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);
}
}
1 change: 1 addition & 0 deletions backend-laravel/routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
});

Route::get('/ville/today', [VilleController::class, 'today']);
Route::get('/villes', [VilleController::class, 'all']);

0 comments on commit 962fc3f

Please sign in to comment.