feat: prevent booking flow without available rooms

This commit is contained in:
Björn Fromme
2026-03-16 11:59:10 +01:00
parent 82b47e314b
commit 7ce3bc18b2
5 changed files with 71 additions and 7 deletions
+6
View File
@@ -4,6 +4,7 @@ namespace App\Service;
use App\BusProNet\Model\Room;
use App\BusProNet\Model\Travel;
use App\Exception\NoRoomsAvailableException;
use App\Form\Model\BookingCreateDto;
use App\Form\Model\RoomSelectionDto;
use Symfony\Component\HttpFoundation\Request;
@@ -78,6 +79,11 @@ class BookingService
$roomsIdsAndQuantities = $this->processRoomQuantities($request);
$availableRooms = $travelData->getAvailableRooms();
// Prevent booking flow entry when no rooms are available
if (empty($availableRooms)) {
throw new NoRoomsAvailableException($dateId, $hotelId);
}
$roomSelections = array_map(
fn (Room $room) => $this->createRoomSelection($room, $roomsIdsAndQuantities),
$availableRooms