62 lines
1.8 KiB
PHP
62 lines
1.8 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace Database\Seeders;
|
||
|
|
||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||
|
use Illuminate\Database\Seeder;
|
||
|
|
||
|
class CinemaSeeder extends Seeder
|
||
|
{
|
||
|
/**
|
||
|
* Run the database seeds.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function run()
|
||
|
{
|
||
|
$cinemas = [
|
||
|
[
|
||
|
'cinema_name' => 'Cinema 1',
|
||
|
'cinema_address' => [
|
||
|
'address_line_1' => '123 Main Street',
|
||
|
'address_line_2' => 'Suite 1',
|
||
|
'address_city' => 'City',
|
||
|
'address_state' => 'State',
|
||
|
'address_zip' => '12345',
|
||
|
'address_phone' => '123-456-7890',
|
||
|
],
|
||
|
],
|
||
|
[
|
||
|
'cinema_name' => 'Cinema 2',
|
||
|
'cinema_address' => [
|
||
|
'address_line_1' => '123 Main Street',
|
||
|
'address_line_2' => 'Suite 2',
|
||
|
'address_city' => 'City',
|
||
|
'address_state' => 'State',
|
||
|
'address_zip' => '12345',
|
||
|
'address_phone' => '123-456-7890',
|
||
|
],
|
||
|
]
|
||
|
];
|
||
|
|
||
|
|
||
|
foreach ($cinemas as $cinema) {
|
||
|
$c = new \App\Models\Cinema();
|
||
|
$c->cinema_name = $cinema['cinema_name'];
|
||
|
$c->user_id = 1;
|
||
|
|
||
|
$a = new \App\Models\Address();
|
||
|
$a->address_street = $cinema['cinema_address']['address_line_1'];
|
||
|
$a->address_city = $cinema['cinema_address']['address_city'];
|
||
|
$a->address_state = $cinema['cinema_address']['address_state'];
|
||
|
$a->address_zip = $cinema['cinema_address']['address_zip'];
|
||
|
$a->address_phone = $cinema['cinema_address']['address_phone'];
|
||
|
$a->save();
|
||
|
|
||
|
$c->address_id = $a->address_id;
|
||
|
$c->save();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|