mega-commit: migrations, controllers, models, etc.
This commit is contained in:
parent
9732135e90
commit
2c6745e812
70 changed files with 2124 additions and 400 deletions
|
@ -32,5 +32,23 @@ class Seat extends Model
|
|||
return $this->belongsToMany(Order::class, 'order_seats', 'seat_id', 'order_id');
|
||||
}
|
||||
|
||||
public function tickets()
|
||||
{
|
||||
return $this->hasMany(Ticket::class, 'seat_id', 'seat_id');
|
||||
}
|
||||
|
||||
// isReserved(int showing_id) method
|
||||
// Looks at showing / order / ticket if it's reserved
|
||||
// Returns true if it is reserved, false if it isn't
|
||||
public function is_reserved(int $showing_id)
|
||||
{
|
||||
$tickets = $this->tickets()->where('showing_id', $showing_id)->get();
|
||||
foreach ($tickets as $ticket) {
|
||||
if ($ticket->order->order_status == 'pending' || $ticket->order->order_status == 'paid') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue