feat: filter teamers by multiple job profiles
This commit is contained in:
@@ -40,11 +40,12 @@ class TeamerFilterType extends AbstractType
|
||||
'label' => 'Snowboardlehrer:innen-Lizenz',
|
||||
'required' => false,
|
||||
])
|
||||
->add('jobProfile', EntityType::class, [
|
||||
'label' => 'Job-Profil',
|
||||
->add('jobProfiles', MultiselectEntityType::class, [
|
||||
'label' => 'Job-Profile',
|
||||
'class' => JobProfile::class,
|
||||
'required' => false,
|
||||
'choice_label' => 'name',
|
||||
'empty_label' => 'nicht filtern',
|
||||
'query_builder' => function (EntityRepository $repository) {
|
||||
return $repository->createQueryBuilder('job_profile')
|
||||
->orderBy('job_profile.name', 'ASC');
|
||||
|
||||
@@ -9,7 +9,7 @@ class TeamerFilterDto extends AbstractFilterDto
|
||||
protected ?string $name = null;
|
||||
protected ?\DateTimeImmutable $dateFrom = null;
|
||||
protected ?\DateTimeImmutable $dateTo = null;
|
||||
protected ?JobProfile $jobProfile = null;
|
||||
protected array $jobProfiles = [];
|
||||
protected string $pickupId = '';
|
||||
protected bool $skiLicense = false;
|
||||
protected bool $snowboardLicense = false;
|
||||
@@ -51,14 +51,14 @@ class TeamerFilterDto extends AbstractFilterDto
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getJobProfile(): ?JobProfile
|
||||
public function getJobProfiles(): array
|
||||
{
|
||||
return $this->jobProfile;
|
||||
return $this->jobProfiles;
|
||||
}
|
||||
|
||||
public function setJobProfile(?JobProfile $jobProfile): static
|
||||
public function setJobProfiles(array $jobProfiles): static
|
||||
{
|
||||
$this->jobProfile = $jobProfile;
|
||||
$this->jobProfiles = $jobProfiles;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -66,10 +66,10 @@ class TeamerRepository extends ServiceEntityRepository
|
||||
;
|
||||
}
|
||||
|
||||
if (null !== $filterDto->getJobProfile()) {
|
||||
if (0 < count($filterDto->getJobProfiles())) {
|
||||
$qb
|
||||
->andWhere($qb->expr()->eq('job_profile', ':jobProfile'))
|
||||
->setParameter('jobProfile', $filterDto->getJobProfile())
|
||||
->andWhere($qb->expr()->in('job_profile', ':jobProfiles'))
|
||||
->setParameter('jobProfiles', $filterDto->getJobProfiles())
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,13 +63,13 @@ class TeamerFilterHandler
|
||||
->setNoTrainings($data['no_trainings'])
|
||||
;
|
||||
|
||||
if (0 < (int) $data['job_profile']) {
|
||||
$jobProfile = $this
|
||||
if (0 < count($data['job_profiles'])) {
|
||||
$jobProfiles = $this
|
||||
->entityManager
|
||||
->getRepository(JobProfile::class)
|
||||
->find($data['job_profile'])
|
||||
->findBy(['id' => $data['job_profiles']])
|
||||
;
|
||||
$filterDto->setJobProfile($jobProfile);
|
||||
$filterDto->setJobProfiles($jobProfiles);
|
||||
}
|
||||
|
||||
return $filterDto;
|
||||
@@ -84,8 +84,10 @@ class TeamerFilterHandler
|
||||
'pickup_id' => $filterDto->getPickupId(),
|
||||
'ski_license' => $filterDto->hasSkiLicense(),
|
||||
'snowboard_license' => $filterDto->hasSnowboardLicense(),
|
||||
'job_profile' => $filterDto->getJobProfile()?->getId(),
|
||||
'no_trainings' => $filterDto->hasNoTrainings(),
|
||||
'job_profiles' => array_map(function (JobProfile $jobProfile) {
|
||||
return $jobProfile->getId();
|
||||
}, $filterDto->getJobProfiles()),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
{{ form_row(filterForm.name) }}
|
||||
{{ form_row(filterForm.dateFrom) }}
|
||||
{{ form_row(filterForm.dateTo) }}
|
||||
{{ form_row(filterForm.jobProfile) }}
|
||||
{{ form_row(filterForm.jobProfiles) }}
|
||||
{{ form_row(filterForm.pickupId) }}
|
||||
{{ form_row(filterForm.skiLicense) }}
|
||||
{{ form_row(filterForm.snowboardLicense) }}
|
||||
|
||||
Reference in New Issue
Block a user