Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
srv
/
data
/
web
/
vhosts
/
716cf56cb2.url-de-test.ws
/
htdocs
/
src
/
Repository
/
/srv/data/web/vhosts/716cf56cb2.url-de-test.ws/htdocs/src/Repository/LogementRepository.php
<?php namespace App\Repository; use App\Entity\Booking; use App\Entity\Logement; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; /** * @extends ServiceEntityRepository<Logement> * * @method Logement|null find($id, $lockMode = null, $lockVersion = null) * @method Logement|null findOneBy(array $criteria, array $orderBy = null) * @method Logement[] findAll() * @method Logement[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ class LogementRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, Logement::class); } public function add(Logement $entity, bool $flush = false): void { $this->getEntityManager()->persist($entity); if ($flush) { $this->getEntityManager()->flush(); } } public function remove(Logement $entity, bool $flush = false): void { $this->getEntityManager()->remove($entity); if ($flush) { $this->getEntityManager()->flush(); } } public function findLogementsNotDeleted(): array { return $this->createQueryBuilder('l') ->andWhere('l.isDelete = false') ->orderBy('l.orderRank', 'ASC') ->getQuery() ->getResult(); } public function findLogementWithConditions($data): array { $subquery = $this->createQueryBuilder('subpl') ->innerJoin('subpl.pricesLogements', 'pl') ->andWhere('pl.date BETWEEN :startDate AND :endDate') ->getQuery() ->getDQL(); return $this->createQueryBuilder('l') ->andWhere('l.isDelete = false') ->orderBy('l.orderRank', 'ASC') ->getQuery() ->getResult(); } public function availableLogements($data): array { $subquery = $this->createQueryBuilder('subl') ->innerJoin('subl.bookings', 'b') ->andWhere('NOT ((:startDate < b.checkin AND :endDate < b.checkin) OR (:startDate >= b.checkout AND :endDate > b.checkout))') ->andWhere('b.isCancel = false') ->andWhere('b.statusAdvance = :paid') ->getQuery() ->getDQL(); $subquery2 = $this->createQueryBuilder('subpl') ->innerJoin('subpl.pricesLogements', 'pl') ->andWhere('pl.date BETWEEN :startDate AND :endDate') ->getQuery() ->getDQL(); $subquery3 = $this->createQueryBuilder('subcd') ->innerJoin('subcd.closureDays', 'cd') ->andWhere('cd.date BETWEEN :startDate AND :endDate') ->getQuery() ->getDQL(); $query = $this->createQueryBuilder('l') ->where('l.id NOT IN (' . $subquery . ')') ->andWhere('l.id NOT IN (' . $subquery3 . ')') ->andWhere('l.isDelete = false') ->orderBy('l.orderRank', 'ASC') ->setParameter('startDate', $data['start']) ->setParameter('endDate', $data['end']) ->setParameter('paid', Booking::STATUS_PAID) ->getQuery() ->getResult(); return $query; } }