<?php

namespace Database\Seeders;

use App\Models\User;
use App\Models\Karyawan;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;

class DatabaseSeeder extends Seeder
{
    use WithoutModelEvents;

    /**
     * Seed the application's database.
     */
    public function run(): void
    {
        $adminKaryawan = Karyawan::create([
            'nrp' => '01.b.23.493',
            'nama' => 'MUHAMMAD IQBAL',
            'jabatan' => 'HCGL',
            'departemen' => 'HCGS',
            'plant' => 'SITE CAM',
            'foto' => null,
            'atasan_id' => null
        ]);

        User::create([
            'name' => 'MUHAMMAD IQBAL',
            'nrp' => '01.b.23.493',
            'password' => Hash::make('123'),
            'role' => 'administrator',
            'karyawan_id' => $adminKaryawan->id
        ]);

        $sh = Karyawan::create([
            'nrp' => '20000001',
            'nama' => 'Syahrial',
            'jabatan' => 'Section Head',
            'departemen' => 'PRODUKSI',
            'plant' => 'SITE CAM',
            'atasan_id' => $adminKaryawan->id
        ]);

        $gl = Karyawan::create([
            'nrp' => '30000001',
            'nama' => 'Rahmat',
            'jabatan' => 'Group Leader',
            'departemen' => 'PRODUKSI',
            'plant' => 'SITE CAM',
            'atasan_id' => $sh->id
        ]);

        User::create([
            'name' => 'Rahmat',
            'nrp' => '30000001',
            'password' => Hash::make('123'),
            'role' => 'user',
            'karyawan_id' => $gl->id
        ]);

        Karyawan::factory(4)->create([
            'departemen' => 'PRODUKSI',
            'plant' => 'SITE CAM',
            'atasan_id' => $gl->id
        ]);
    }
}
