fix+add: seats + seat-chooser

This commit is contained in:
Didier Slof 2023-01-01 20:13:11 +01:00
parent 2c6745e812
commit b0cc5b5278
Signed by: didier
GPG key ID: 01E71F18AA4398E5
31 changed files with 808 additions and 115 deletions

View file

@ -13,7 +13,8 @@ class Seat extends Model
protected $fillable = [
'seat_row',
'seat_number',
'seat_type', // enum('standard', 'wheelchair', 'loveseat')
'seat_type', // enum('standard', 'wheelchair', 'loveseat', 'not_available')
'seat_linked_id', // if this is a loveseat, this is the other seat
'room_id',
];
@ -27,28 +28,27 @@ class Seat extends Model
return $this->belongsTo(Room::class, 'room_id', 'room_id');
}
public function orders()
{
return $this->belongsToMany(Order::class, 'order_seats', 'seat_id', 'order_id');
}
public function tickets()
{
return $this->hasMany(Ticket::class, 'seat_id', 'seat_id');
}
public function linked_seat()
{
return $this->belongsTo(Seat::class, 'seat_linked_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)
public function isReserved(int $showing_id): bool
{
$tickets = $this->tickets()->where('showing_id', $showing_id)->get();
$tickets = $this->tickets->where('showing_id', $showing_id);
foreach ($tickets as $ticket) {
if ($ticket->order->order_status == 'pending' || $ticket->order->order_status == 'paid') {
if ($ticket->showing_id == $showing_id) {
return true;
}
}
return false;
}
}