Add image entity

This commit is contained in:
2024-11-15 10:02:58 +01:00
parent 325e255d75
commit b1c9fdbdf7
6 changed files with 256 additions and 14 deletions

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Repository;
use App\Entity\Image;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Image>
*/
class ImageRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Image::class);
}
// /**
// * @return Image[] Returns an array of Image objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('i')
// ->andWhere('i.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('i.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?Image
// {
// return $this->createQueryBuilder('i')
// ->andWhere('i.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@@ -16,6 +16,23 @@ class SiteRepository extends ServiceEntityRepository
parent::__construct($registry, Site::class);
}
public function coordinates(int $id): array|bool
{
$conn = $this->getEntityManager()->getConnection();
$sql = '
SELECT
ST_X(ST_AsText(coordinate)) as lng,
ST_Y(ST_AsText(coordinate)) as lat
FROM
sito
WHERE id = :id
';
return $conn->executeQuery($sql, ['id' => $id])
->fetchAssociative();
}
// /**
// * @return Site[] Returns an array of Site objects
// */