Skip to content

Commit

Permalink
seats
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiritin committed Sep 18, 2024
1 parent 9ec2f0b commit 49f1da7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/Http/Controllers/BookingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 49f1da7

Please sign in to comment.