forme création sortie

This commit is contained in:
marvin
2024-11-19 14:04:47 +01:00
parent 51fcbba8b2
commit 6403b41a3e
9 changed files with 344 additions and 0 deletions

View 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);
}
}