wip: api endpoint for calendar data to be consumed by cms

This commit is contained in:
Björn Fromme committed 2026-07-16 09:03:42 +02:00
1 parent 5247135025
commit 423ffafb9e
3 files changed
+132 -24

No files matched your search

@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Repository\Groups;
use App\Entity\Groups\AccommodationPrice;
@@ -16,28 +18,27 @@ class AccommodationPriceRepository extends ServiceEntityRepository
parent::__construct($registry, AccommodationPrice::class);
}
// /**
// * @return AccommodationPrice[] Returns an array of AccommodationPrice objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('a')
// ->andWhere('a.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('a.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?AccommodationPrice
// {
// return $this->createQueryBuilder('a')
// ->andWhere('a.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
/**
* Returns all AccommodationPrice records whose period overlaps with [dateFrom, dateTo]
* for the accommodation identified by the given hotel code.
*
* @return AccommodationPrice[]
*/
public function findByHotelCodeAndDateRange(
string $hotelCode,
\DateTimeImmutable $dateFrom,
\DateTimeImmutable $dateTo,
): array {
return $this->createQueryBuilder('ap')
->join('ap.accommodation', 'a')
->where('a.code = :hotelCode')
->andWhere('ap.dateFrom <= :dateTo')
->andWhere('ap.dateTo >= :dateFrom')
->setParameter('hotelCode', $hotelCode)
->setParameter('dateFrom', $dateFrom)
->setParameter('dateTo', $dateTo)
->orderBy('ap.dateFrom', 'ASC')
->getQuery()
->getResult();
}
}