*/ class AccommodationPriceRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, AccommodationPrice::class); } /** * 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.calendarCode = :hotelCode') ->andWhere('ap.dateFrom <= :dateTo') ->andWhere('ap.dateTo >= :dateFrom') ->setParameter('hotelCode', $hotelCode) ->setParameter('dateFrom', $dateFrom) ->setParameter('dateTo', $dateTo) ->orderBy('ap.dateFrom', 'ASC') ->getQuery() ->getResult(); } }