feat: filter destinations by common name

This commit is contained in:
Björn Fromme
2024-10-28 09:09:17 +01:00
parent 80cd9ca17f
commit f155b5ae52
4 changed files with 41 additions and 36 deletions
+3 -19
View File
@@ -4,7 +4,6 @@ namespace App\Repository;
use App\Entity\Application;
use App\Entity\Assignment;
use App\Entity\Destination;
use App\Entity\Teamer;
use App\Model\AssignmentFilterDto;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
@@ -119,10 +118,10 @@ class AssignmentRepository extends ServiceEntityRepository
;
}
if ($hotelCodes = $filterDto->getHotels()) {
foreach ($filterDto->getHotels() as $hotel) {
$qb
->andWhere($qb->expr()->in('destination.hotelCode', ':hotelCodes'))
->setParameter('hotelCodes', $hotelCodes)
->andWhere($qb->expr()->like('destination.product', ':hotel'))
->setParameter('hotel', '%'.$hotel.'%')
;
}
@@ -205,21 +204,6 @@ class AssignmentRepository extends ServiceEntityRepository
return $assignment->getJobProfile();
}, $result);
// Hotels
$qb = $this->createQueryBuilder('assignment');
$result = $qb
->select('assignment', 'destination')
->innerJoin('assignment.destination', 'destination')
->where($qb->expr()->isNull('assignment.deletedAt'))
->groupBy('destination.hotelBusProId')
->orderBy('destination.hotel', 'ASC')
->getQuery()
->getResult()
;
$options['hotels'] = array_map(function (Assignment $assignment) {
return $assignment->getDestination();
}, $result);
return $options;
}