feat: offer only free rooms in booking step 1
This commit is contained in:
1 parent
980e378a7b
commit
2b27b9809d
6 files changed
+17
-119
No files matched your search
@@ -278,10 +278,10 @@ class Travel
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all bookable rooms (both regular and inquiry).
|
||||
* Retrieves all bookable rooms.
|
||||
*
|
||||
* Returns rooms that have availability greater than zero and a bookable status
|
||||
* (either 'Frei' for regular booking or 'Anfrage' for inquiry booking).
|
||||
* Returns rooms with status 'Frei' and availability greater than zero. Rooms on request
|
||||
* ('Anfrage') are not offered: they would turn the booking into an inquiry.
|
||||
*
|
||||
* @return array<int, Room> The filtered array of bookable rooms, indexed by room ID
|
||||
*/
|
||||
@@ -289,7 +289,7 @@ class Travel
|
||||
{
|
||||
$result = [];
|
||||
foreach ($this->rooms as $room) {
|
||||
if ($room->available > 0 && $this->isBookableRoomStatus($room->status)) {
|
||||
if ($room->available > 0 && Constants::STATUS_AVAILABLE === $room->status) {
|
||||
$result[$room->id] = $room;
|
||||
}
|
||||
}
|
||||
@@ -307,40 +307,6 @@ class Travel
|
||||
return [] !== $this->getAvailableRooms();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if all bookable rooms require inquiry booking.
|
||||
*
|
||||
* Returns true if there are bookable rooms but none with 'Frei' status.
|
||||
* This indicates the booking must be submitted as an inquiry.
|
||||
*
|
||||
* @return bool True if only inquiry rooms are available
|
||||
*/
|
||||
public function requiresInquiryBooking(): bool
|
||||
{
|
||||
$bookableRooms = $this->getAvailableRooms();
|
||||
|
||||
if ([] === $bookableRooms) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($bookableRooms as $room) {
|
||||
if (Constants::STATUS_AVAILABLE === $room->status) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a room status allows booking.
|
||||
*/
|
||||
private function isBookableRoomStatus(?string $status): bool
|
||||
{
|
||||
return Constants::STATUS_AVAILABLE === $status
|
||||
|| Constants::STATUS_ON_REQUEST === $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a room by its ID.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user