wip: booking process, room assignment

This commit is contained in:
Björn Fromme
2025-07-18 15:40:23 +02:00
parent eecea0abd1
commit 6feb8178b5
12 changed files with 454 additions and 201 deletions
+4 -38
View File
@@ -4,16 +4,15 @@ namespace App\Form\Model;
use App\BusProNet\Model\Travel;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
class BookingCreateDto
{
public int $currentStep = 1;
#[Assert\Valid]
/**
* @var array<int, RoomSelectionDto>
*/
#[Assert\Valid]
public array $roomSelections = [];
/**
@@ -26,42 +25,9 @@ class BookingCreateDto
{
}
#[Assert\Callback(groups: ['booking_create_step_1'])]
public function assertValidRoomSelections(ExecutionContextInterface $context): void
{
$participantsCount = $this->getParticipantsCount();
$selectedContingent = 0;
foreach ($this->roomSelections as $roomSelection) {
$selectedContingent += $roomSelection->quantity * $roomSelection->minPax;
}
if (0 === $selectedContingent) {
$context->buildViolation('Bitte mindestens ein Zimmer auswählen.')
->atPath('roomSelections')
->addViolation();
}
if ($selectedContingent !== $participantsCount) {
$context->buildViolation('Die ausgewählten Zimmer passen nicht zur Teilnehmerzahl.')
->atPath('roomSelections')
->addViolation();
}
}
public function getParticipantsCount(): int
{
$participantsCount = 0;
$rooms = $this->travelData->getAvailableRooms();
foreach ($this->roomSelections as $roomSelection) {
$room = $rooms[$roomSelection->roomId];
$participantsCount += $room->minPax * $roomSelection->quantity;
}
return $participantsCount;
}
/**
* @return array<int, RoomSelectionDto>
*/
public function getSelectedRooms(): array
{
return array_filter($this->roomSelections, function (RoomSelectionDto $roomSelection) {
+4
View File
@@ -37,6 +37,10 @@ class ParticipantDto
public ?string $email = null;
public ?string $mobile = null;
#[Assert\NotNull(message: 'Bitte ein Zimmer auswählen', groups: ['booking_create_step_2'])]
public ?int $assignedRoomId = null;
public array $courses = [];
public array $additionalServices = [];
public array $skiPass = [];