feat: simplify handling of ski pass service
This commit is contained in:
@@ -120,11 +120,15 @@ class BookingDataProcessor
|
||||
$servicesToMap = [
|
||||
...$participant->courses,
|
||||
...$participant->additionalServices,
|
||||
...($participant->skiPass ? [$participant->skiPass] : []),
|
||||
...$participant->board,
|
||||
...$participant->rentals,
|
||||
];
|
||||
|
||||
// Add ski pass if selected (single service, not an array)
|
||||
if (null !== $participant->skiPass) {
|
||||
$servicesToMap[] = $participant->skiPass;
|
||||
}
|
||||
|
||||
foreach ($servicesToMap as $service) {
|
||||
if (false === isset($bookingData->additionalServices[$service->id])) {
|
||||
$serviceToAdd = $travelData->additionalServices[$service->id] ?? null;
|
||||
|
||||
@@ -150,6 +150,29 @@ class Booking
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves ski pass for a specific participant.
|
||||
*
|
||||
* Since each participant can only have one ski pass, this method returns
|
||||
* the single ski pass assigned to the participant or null if none is assigned.
|
||||
*
|
||||
* @param int $participantIndex The participant index to search for
|
||||
*
|
||||
* @return Service|null The participant's ski pass or null if not found
|
||||
*/
|
||||
public function getSkiPassForParticipant(int $participantIndex): ?Service
|
||||
{
|
||||
$skiPasses = $this->getAdditionalServicesByGroup('SPA');
|
||||
|
||||
foreach ($skiPasses as $service) {
|
||||
if (in_array($participantIndex, $service->mapping)) {
|
||||
return $service;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves room assignment for a specific participant.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user