<?php

namespace Database\Seeders;

use App\Models\Employee;
use App\Models\Holiday;
use App\Models\LeaveRequest;
use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    public function run(): void
    {
        $employees = collect([
            ['nip' => '198901012015012001', 'name' => 'Ns. Nur Aini', 'role' => 'Pimpinan', 'unit' => 'Rawat Inap', 'status' => 'Aktif'],
            ['nip' => '199104122018012002', 'name' => 'Ns. Sari Puspita', 'role' => 'PJ', 'unit' => 'Rawat Inap', 'status' => 'Aktif'],
            ['nip' => '199306202019032004', 'name' => 'Ns. Dewi Lestari', 'role' => 'PJ', 'unit' => 'Rawat Inap', 'status' => 'Aktif'],
            ['nip' => '199508082020121005', 'name' => 'Ns. Andi Pratama', 'role' => 'Perawat', 'unit' => 'Rawat Inap', 'status' => 'Aktif'],
            ['nip' => '199202142017022003', 'name' => 'Ns. Rina Amelia', 'role' => 'Perawat', 'unit' => 'Rawat Inap', 'status' => 'Cuti'],
            ['nip' => '199612112021041006', 'name' => 'Ns. Fajar Hidayat', 'role' => 'Perawat', 'unit' => 'Rawat Inap', 'status' => 'Aktif'],
            ['nip' => '199701042022051007', 'name' => 'Ns. Tika Maharani', 'role' => 'Perawat', 'unit' => 'Rawat Inap', 'status' => 'Aktif'],
            ['nip' => '199811232023061008', 'name' => 'Ns. M. Rizki', 'role' => 'Perawat', 'unit' => 'Rawat Inap', 'status' => 'Aktif'],
        ])->mapWithKeys(fn (array $data) => [$data['name'] => Employee::create($data)]);

        Holiday::insert([
            ['date' => '2026-06-01', 'name' => 'Hari Lahir Pancasila', 'type' => 'Nasional', 'created_at' => now(), 'updated_at' => now()],
            ['date' => '2026-06-17', 'name' => 'Tahun Baru Islam', 'type' => 'Nasional', 'created_at' => now(), 'updated_at' => now()],
            ['date' => '2026-06-24', 'name' => 'Pemeliharaan Unit Internal', 'type' => 'Internal', 'created_at' => now(), 'updated_at' => now()],
        ]);

        LeaveRequest::create(['employee_id' => $employees['Ns. Rina Amelia']->id, 'type' => 'Cuti', 'start_date' => '2026-06-02', 'end_date' => '2026-06-04', 'status' => 'Disetujui']);
        LeaveRequest::create(['employee_id' => $employees['Ns. Fajar Hidayat']->id, 'type' => 'Sakit', 'start_date' => '2026-06-01', 'end_date' => '2026-06-01', 'status' => 'Disetujui']);
        LeaveRequest::create(['employee_id' => $employees['Ns. Dewi Lestari']->id, 'type' => 'Libur Pengganti', 'start_date' => '2026-06-08', 'end_date' => '2026-06-08', 'status' => 'Menunggu']);
    }
}
