mega-commit: migrations, controllers, models, etc.
This commit is contained in:
parent
9732135e90
commit
2c6745e812
70 changed files with 2124 additions and 400 deletions
57
database/seeders/RoomSeeder.php
Normal file
57
database/seeders/RoomSeeder.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue