mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-08 02:50:32 +00:00
6.9 - Respecting Reservations
This commit is contained in:
@@ -58,7 +58,9 @@ class Concert extends Model
|
||||
|
||||
public function reserveTickets($quantity)
|
||||
{
|
||||
return $this->findTickets($quantity);
|
||||
return $this->findTickets($quantity)->each(function ($ticket) {
|
||||
$ticket->reserve();
|
||||
});
|
||||
}
|
||||
|
||||
public function findTickets($quantity)
|
||||
|
||||
@@ -31,7 +31,7 @@ class ConcertOrdersController extends Controller
|
||||
|
||||
try {
|
||||
// Find some tickets
|
||||
$tickets = $concert->findTickets(request('ticket_quantity'));
|
||||
$tickets = $concert->reserveTickets(request('ticket_quantity'));
|
||||
$reservation = new Reservation($tickets);
|
||||
|
||||
// Charge the customer for the tickets
|
||||
|
||||
@@ -11,7 +11,7 @@ class Ticket extends Model
|
||||
|
||||
public function scopeAvailable($query)
|
||||
{
|
||||
return $query->whereNull('order_id');
|
||||
return $query->whereNull('order_id')->whereNull('reserved_at');
|
||||
}
|
||||
|
||||
public function reserve()
|
||||
|
||||
Reference in New Issue
Block a user