64 lines
1.8 KiB
PHP
Executable File
64 lines
1.8 KiB
PHP
Executable File
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\Marker;
|
|
use App\Models\User;
|
|
use App\Models\VacationPeriod;
|
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
class DatabaseSeeder extends Seeder
|
|
{
|
|
use WithoutModelEvents;
|
|
|
|
/**
|
|
* Seed the application's database.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
$user = User::factory()->create([
|
|
'name' => 'Demo User',
|
|
'email' => 'demo@example.com',
|
|
]);
|
|
|
|
$year = (int) date('Y');
|
|
|
|
$me = Marker::factory()->for($user)->create([
|
|
'name' => 'Я',
|
|
'color' => '#2563eb',
|
|
]);
|
|
|
|
$anna = Marker::factory()->for($user)->create([
|
|
'name' => 'Анна',
|
|
'color' => '#db2777',
|
|
]);
|
|
|
|
$igor = Marker::factory()->for($user)->create([
|
|
'name' => 'Игорь',
|
|
'color' => '#16a34a',
|
|
]);
|
|
|
|
VacationPeriod::factory()->for($user)->for($me)->create([
|
|
'start_date' => Carbon::create($year, 7, 6)->toDateString(),
|
|
'end_date' => Carbon::create($year, 7, 19)->toDateString(),
|
|
]);
|
|
|
|
VacationPeriod::factory()->for($user)->for($me)->create([
|
|
'start_date' => Carbon::create($year, 12, 28)->toDateString(),
|
|
'end_date' => Carbon::create($year + 1, 1, 8)->toDateString(),
|
|
]);
|
|
|
|
VacationPeriod::factory()->for($user)->for($anna)->create([
|
|
'start_date' => Carbon::create($year, 7, 13)->toDateString(),
|
|
'end_date' => Carbon::create($year, 7, 26)->toDateString(),
|
|
]);
|
|
|
|
VacationPeriod::factory()->for($user)->for($igor)->create([
|
|
'start_date' => Carbon::create($year, 8, 3)->toDateString(),
|
|
'end_date' => Carbon::create($year, 8, 9)->toDateString(),
|
|
]);
|
|
}
|
|
}
|