58 lines
1.6 KiB
PHP
58 lines
1.6 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace Database\Seeders;
|
||
|
|
||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||
|
use Illuminate\Database\Seeder;
|
||
|
|
||
|
class RoomSeeder extends Seeder
|
||
|
{
|
||
|
/**
|
||
|
* Run the database seeds.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function run()
|
||
|
{
|
||
|
foreach (\App\Models\Cinema::all() as $cinema) {
|
||
|
$rooms = [
|
||
|
[
|
||
|
'room_name' => 'Room 1',
|
||
|
'room_rows' => 10,
|
||
|
'room_columns' => 10,
|
||
|
],
|
||
|
[
|
||
|
'room_name' => 'Room 2',
|
||
|
'room_rows' => 10,
|
||
|
'room_columns' => 10,
|
||
|
],
|
||
|
[
|
||
|
'room_name' => 'Room 3',
|
||
|
'room_rows' => 10,
|
||
|
'room_columns' => 10,
|
||
|
],
|
||
|
];
|
||
|
|
||
|
foreach ($rooms as $room) {
|
||
|
$r = new \App\Models\Room();
|
||
|
$r->room_name = $room['room_name'];
|
||
|
$r->room_rows = $room['room_rows'];
|
||
|
$r->room_columns = $room['room_columns'];
|
||
|
$r->user_id = 1;
|
||
|
$r->cinema_id = $cinema->cinema_id;
|
||
|
$r->save();
|
||
|
|
||
|
for ($row = 1; $row <= $r->room_rows; $row++) {
|
||
|
for ($column = 1; $column <= $r->room_columns; $column++) {
|
||
|
$s = new \App\Models\Seat();
|
||
|
$s->seat_row = $row;
|
||
|
$s->seat_column = $column;
|
||
|
$s->room_id = $r->room_id;
|
||
|
$s->save();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|