Add Finding (WIP)
This commit is contained in:
29
src/Controller/FindingController.php
Normal file
29
src/Controller/FindingController.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use App\Entity\Finding;
|
||||
|
||||
class FindingController extends AbstractController
|
||||
{
|
||||
#[Route('/finding', name: 'app_finding')]
|
||||
public function index(EntityManagerInterface $em): JsonResponse
|
||||
{
|
||||
$repo = $em->getRepository(Finding::class);
|
||||
|
||||
$findings = $repo->findAll();
|
||||
|
||||
foreach($findings as $key => $finding) {
|
||||
$coords = $repo->coordinates($finding->getId());
|
||||
$finding->setLat($coords['lat']);
|
||||
$finding->setLng($coords['lng']);
|
||||
$findings[$key] = $finding;
|
||||
}
|
||||
|
||||
return $this->json($findings);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user