51 lines
1.5 KiB
PHP
51 lines
1.5 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace Database\Seeders;
|
||
|
|
||
|
use App\Models\User;
|
||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||
|
use Illuminate\Database\Seeder;
|
||
|
|
||
|
class ShowingSeeder extends Seeder
|
||
|
{
|
||
|
/**
|
||
|
* Run the database seeds.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function run()
|
||
|
{
|
||
|
// $showStart = <current time + 5days>;
|
||
|
|
||
|
$showStart = new \DateTime();
|
||
|
$showStart->add(new \DateInterval('P5D'));
|
||
|
|
||
|
foreach (\App\Models\Room::all() as $room) {
|
||
|
$showings = [
|
||
|
[
|
||
|
'showing_start' => $showStart->format('Y-m-d H:i:s'),
|
||
|
'showing_end' => $showStart->add(new \DateInterval('PT2H'))->format('Y-m-d H:i:s'),
|
||
|
'movie_id' => 1,
|
||
|
'room_id' => $room->room_id,
|
||
|
],
|
||
|
[
|
||
|
'showing_start' => $showStart->add(new \DateInterval('PT2H'))->format('Y-m-d H:i:s'),
|
||
|
'showing_end' => $showStart->add(new \DateInterval('PT2H'))->format('Y-m-d H:i:s'),
|
||
|
'movie_id' => 2,
|
||
|
'room_id' => $room->room_id,
|
||
|
],
|
||
|
];
|
||
|
|
||
|
foreach ($showings as $showing) {
|
||
|
$s = new \App\Models\Showing();
|
||
|
$s->showing_start = $showing['showing_start'];
|
||
|
$s->movie_id = $showing['movie_id'];
|
||
|
$s->room_id = $showing['room_id'];
|
||
|
$s->user_id = 1;
|
||
|
$s->save();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|