Add underwater sites

This commit is contained in:
2025-04-29 10:50:10 +02:00
parent b84d4589fe
commit 2fa1d2d99e
3 changed files with 251 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
use App\Entity\Underwater;
use Doctrine\ORM\EntityManagerInterface;
class UnderwaterController extends AbstractController
{
#[Route('/underwater', name: 'app_underwater')]
public function index(EntityManagerInterface $em): JsonResponse
{
$repo = $em->getRepository(Underwater::class);
$underwater = $repo->findAll();
foreach ($underwater as $under) {
$coords = $repo->coordinates($under->getId());
$under->setLat($coords['lat']);
$under->setLng($coords['lng']);
}
return $this->json($underwater);
}
}