Add underwater sites
This commit is contained in:
28
src/Controller/UnderwaterController.php
Normal file
28
src/Controller/UnderwaterController.php
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user