feat: filtering of custom destinations by hotel

This commit is contained in:
Björn Fromme committed 2025-07-22 17:42:06 +02:00
1 parent ea574427fb
commit e0ce495b86
8 files changed
+233 -1

No files matched your search

+26
View File
@@ -3,6 +3,7 @@
namespace App\Repository;
use App\Entity\Destination;
use App\Model\DestinationFilterDto;
use App\Repository\Traits\QueryHelperTrait;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\Query;
@@ -25,6 +26,31 @@ class DestinationRepository extends ServiceEntityRepository
parent::__construct($registry, Destination::class);
}
public function getListQuery(DestinationFilterDto $filterDto): Query
{
$qb = $this->createQueryBuilder('destination');
$qb->where(
$qb->expr()->andX(
$qb->expr()->isNull('destination.deletedAt'),
$qb->expr()->isNull('destination.busProId')
)
);
if (0 < count($filterDto->getHotels())) {
$constraints = [];
foreach ($filterDto->getHotels() as $index => $hotel) {
$constraints[] = $qb->expr()->like('destination.hotel', ':hotel'.$index);
}
$qb->andWhere($qb->expr()->orX(...$constraints));
foreach ($filterDto->getHotels() as $index => $hotel) {
$qb->setParameter('hotel'.$index, '%'.$hotel.'%');
}
}
return $qb->getQuery();
}
public function getListQueryForCustom(): Query
{
$qb = $this->createQueryBuilder('destination');