From 49f1da74835e5a6bf952f5a4b2233afdad4692f8 Mon Sep 17 00:00:00 2001 From: Tin Date: Wed, 18 Sep 2024 10:35:53 +0200 Subject: [PATCH] seats --- app/Http/Controllers/BookingController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index 941c29d..a1dc562 100644 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -64,6 +64,10 @@ public function store(Request $request, Event $event) if ($bookings + count($data['seats']) > 2) { return redirect()->route('bookings.index')->with(['message' => 'You can only book 2 seats per event.']); } + // Allow no more than max seats + if ($event->seats_left <= 0) { + return redirect()->route('bookings.index')->with(['message' => 'There are no seats available.']); + } } // Start DB Transaction DB::transaction(function () use ($event, $data) {