fix+add: seats + seat-chooser
This commit is contained in:
parent
2c6745e812
commit
b0cc5b5278
31 changed files with 808 additions and 115 deletions
|
@ -43,4 +43,29 @@ class Room extends Model
|
|||
return $this->belongsTo(Cinema::class, 'cinema_id', 'cinema_id');
|
||||
}
|
||||
|
||||
public function seatMatrix($showing_id = null)
|
||||
{
|
||||
$seats = $this->seats;
|
||||
$matrix = [];
|
||||
// first, create an empty matrix
|
||||
for ($i = 0; $i < $this->room_rows-1; $i++) {
|
||||
$matrix[$i] = [];
|
||||
for ($j = 0; $j < $this->room_columns-1; $j++) {
|
||||
$matrix[$i][$j] = null;
|
||||
}
|
||||
}
|
||||
// then, fill it with the seats
|
||||
foreach ($seats as $seat) {
|
||||
$matrix[$seat->seat_row-1][$seat->seat_column-1] = [
|
||||
'seat_id' => $seat->seat_id,
|
||||
'seat_row' => $seat->seat_row,
|
||||
'seat_column' => $seat->seat_column,
|
||||
'seat_type' => $seat->seat_type,
|
||||
'seat_linked_id' => $seat->seat_linked_id,
|
||||
'reserved' => $showing_id ? $seat->isReserved($showing_id) : false,
|
||||
];
|
||||
}
|
||||
return $matrix;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue