2022-12-08 09:30:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\View\Components;
|
|
|
|
|
|
|
|
use App\Models\Room;
|
|
|
|
use Illuminate\View\Component;
|
|
|
|
|
|
|
|
class SeatChooser extends Component
|
|
|
|
{
|
|
|
|
|
|
|
|
public int $room_id;
|
|
|
|
public int $showing_id;
|
|
|
|
public Room $room;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new component instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct(int $room_id, int $showing_id)
|
|
|
|
{
|
|
|
|
$this->room_id = $room_id;
|
|
|
|
$this->room = Room::find($room_id);
|
|
|
|
$this->showing_id = $showing_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function matrixGenerate() {
|
2023-01-01 20:13:11 +01:00
|
|
|
// returns a matrix of seats
|
|
|
|
$m = [];
|
|
|
|
// first make empty matrix
|
|
|
|
for ($i = 0; $i < $this->room->room_rows-1; $i++) {
|
|
|
|
$m[$i] = [];
|
|
|
|
for ($j = 0; $j < $this->room->room_columns-1; $j++) {
|
|
|
|
$m[$i][$j] = null;
|
2022-12-08 09:30:07 +01:00
|
|
|
}
|
|
|
|
}
|
2023-01-01 20:13:11 +01:00
|
|
|
$seats = $this->room->seats;
|
|
|
|
foreach ($seats as $seat) {
|
|
|
|
$m[$seat->seat_row][$seat->seat_column] = $seat;
|
|
|
|
}
|
|
|
|
return $m;
|
2022-12-08 09:30:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the view / contents that represent the component.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Contracts\View\View|\Closure|string
|
|
|
|
*/
|
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
return view('components.seat-chooser', [
|
|
|
|
'room' => $this->room,
|
|
|
|
'seatmatrix' => $this->matrixGenerate(),
|
|
|
|
'showing_id' => $this->showing_id,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|