wip: improved booking summary

This commit is contained in:
Björn Fromme
2026-03-16 11:59:09 +01:00
parent 727ee9b014
commit 65a33922cf
11 changed files with 168 additions and 90 deletions
+16
View File
@@ -17,6 +17,9 @@ use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
*/
class Room
{
public const SELECTION_TYPE_BY_PAX = 'by_pax';
public const SELECTION_TYPE_BY_ROOM = 'by_room';
#[Groups(['api:list', 'api:single'])]
public ?int $id = null;
@@ -72,4 +75,17 @@ class Room
#[Groups(['booking'])]
public array $individualPrice = [];
/**
* Determines the selection type of the room based on its label.
*
* @return string Either self::SELECTION_TYPE_BY_PAX or self::SELECTION_TYPE_BY_ROOM
*/
public function getSelectionType(): string
{
if (1 === preg_match('/bett/i', $this->label)) {
return self::SELECTION_TYPE_BY_PAX;
}
return self::SELECTION_TYPE_BY_ROOM;
}
}
+8 -4
View File
@@ -188,12 +188,16 @@ class Travel
* greater than zero and have an available status. This ensures only
* bookable rooms are returned for selection.
*
* @return array<Room> The filtered array of available rooms
* @return array<int, Room> The filtered array of available rooms, indexed by room ID
*/
public function getAvailableRooms(): array
{
return array_filter($this->rooms, function (Room $room) {
return $room->available > 0 && Constants::STATUS_AVAILABLE === $room->status;
});
$result = [];
foreach ($this->rooms as $room) {
if ($room->available > 0 && Constants::STATUS_AVAILABLE === $room->status) {
$result[$room->id] = $room;
}
}
return $result;
}
}