fix: correctly filter by multiple hotels

This commit is contained in:
Björn Fromme
2025-01-21 15:58:12 +01:00
parent f3ed4ca15d
commit 81a34d73c2
+9 -5
View File
@@ -127,11 +127,15 @@ class AssignmentRepository extends ServiceEntityRepository
;
}
foreach ($filterDto->getHotels() as $hotel) {
$qb
->andWhere($qb->expr()->like('destination.hotel', ':hotel'))
->setParameter('hotel', '%'.$hotel.'%')
;
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.'%');
}
}
if (null !== $duration = $filterDto->getDuration()) {