<?php

declare(strict_types=1);

namespace Database\Seeders;

use App\Models\Shift;
use Illuminate\Database\Seeder;

class ShiftSeeder extends Seeder
{
    /**
     * @var array<string, array{name: string, starts_at: string, ends_at: string}>
     */
    private const SHIFTS = [
        'A' => [
            'name' => 'Shift A',
            'starts_at' => '06:00:00',
            'ends_at' => '14:00:00',
        ],
        'B' => [
            'name' => 'Shift B',
            'starts_at' => '14:00:00',
            'ends_at' => '22:00:00',
        ],
        'C' => [
            'name' => 'Shift C',
            'starts_at' => '22:00:00',
            'ends_at' => '06:00:00',
        ],
        'Night' => [
            'name' => 'Night Shift',
            'starts_at' => '22:00:00',
            'ends_at' => '06:00:00',
        ],
    ];

    public function run(): void
    {
        foreach (self::SHIFTS as $code => $shift) {
            Shift::query()->updateOrCreate(
                ['code' => $code],
                [
                    'name' => $shift['name'],
                    'starts_at' => $shift['starts_at'],
                    'ends_at' => $shift['ends_at'],
                    'description' => null,
                    'is_active' => true,
                ],
            );
        }
    }
}
