feat: filter assignments by hotel in favor of destination

This commit is contained in:
Björn Fromme
2024-02-28 13:10:52 +01:00
parent e0522bdf53
commit a668dcb326
7 changed files with 41 additions and 34 deletions
+7 -7
View File
@@ -106,10 +106,10 @@ class AssignmentRepository extends ServiceEntityRepository
;
}
if (null !== $destination = $filterDto->getDestination()) {
if (null !== $hotelCode = $filterDto->getHotel()) {
$qb
->andWhere($qb->expr()->eq('assignment.destination', ':destination'))
->setParameter('destination', $destination)
->andWhere($qb->expr()->eq('destination.hotelCode', ':hotelCode'))
->setParameter('hotelCode', $hotelCode)
;
}
@@ -186,18 +186,18 @@ class AssignmentRepository extends ServiceEntityRepository
return $assignment->getJobProfile();
}, $result);
// Destinations
// Hotels
$qb = $this->createQueryBuilder('assignment');
$result = $qb
->select('assignment', 'destination')
->innerJoin('assignment.destination', 'destination')
->where($qb->expr()->isNull('assignment.deletedAt'))
->orderBy('destination.product', 'ASC')
->groupBy('destination.id')
->groupBy('destination.hotelBusProId')
->orderBy('destination.hotel', 'ASC')
->getQuery()
->getResult()
;
$options['destinations'] = array_map(function (Assignment $assignment) {
$options['hotels'] = array_map(function (Assignment $assignment) {
return $assignment->getDestination();
}, $result);