mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-20 15:55:18 +00:00
6.8 - Reserving Individual Tickets
This commit is contained in:
@@ -56,6 +56,11 @@ class Concert extends Model
|
||||
return $this->createOrder($email, $tickets);
|
||||
}
|
||||
|
||||
public function reserveTickets($quantity)
|
||||
{
|
||||
return $this->findTickets($quantity);
|
||||
}
|
||||
|
||||
public function findTickets($quantity)
|
||||
{
|
||||
$tickets = $this->tickets()->available()->take($quantity)->get();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Ticket extends Model
|
||||
@@ -13,6 +14,11 @@ class Ticket extends Model
|
||||
return $query->whereNull('order_id');
|
||||
}
|
||||
|
||||
public function reserve()
|
||||
{
|
||||
$this->update(['reserved_at' => Carbon::now()]);
|
||||
}
|
||||
|
||||
public function release()
|
||||
{
|
||||
$this->update(['order_id' => null]);
|
||||
|
||||
Reference in New Issue
Block a user