forme création sortie
This commit is contained in:
28
src/Controller/VilleController.php
Normal file
28
src/Controller/VilleController.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Ville;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
class VilleController extends AbstractController
|
||||
{
|
||||
#[Route('/get-lieux/{id}', name: 'get_lieux')]
|
||||
public function getLieux(Ville $ville): JsonResponse
|
||||
{
|
||||
$lieux = $ville->getLieux();
|
||||
|
||||
$data = [];
|
||||
foreach ($lieux as $lieu) {
|
||||
$data[] = [
|
||||
'id' => $lieu->getIdLieu(),
|
||||
'nom' => $lieu->getNom(),
|
||||
];
|
||||
}
|
||||
|
||||
return new JsonResponse($data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user