<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\User;
use Illuminate\Support\Facades\Hash;

class AkunSeeder extends Seeder
{
    public function run(): void
    {
        /*
        |--------------------------------------------------------------------------
        | SUPER ADMIN
        |--------------------------------------------------------------------------
        | Super Admin memiliki akses penuh terhadap sistem.
        */
        User::updateOrCreate(
            ['username' => 'sutowo_superadmin'],
            [
                'name'     => 'SUTOWO, SE, M.Si',
                'email'    => 'superadmin@mail.com',
                'password' => Hash::make('password123'),
                'role'     => 'superadmin',
                'jabatan'  => 'Kepala Bidang Pengawasan Ketenagakerjaan',
            ]
        );

        /*
        |--------------------------------------------------------------------------
        | ADMIN
        |--------------------------------------------------------------------------
        | Admin hanya digunakan untuk membuat akun pegawai/user.
        */
        $admins = [
            [
                'name'     => 'WELPRIDA IRANI, SH, M.Si',
                'username' => 'welprida_admin',
                'email'    => 'welprida@admin.com',
                'jabatan'  => 'Kepala Seksi Penegakan Hukum',
            ],
            [
                'name'     => 'RINI YULIASTI, ST.,MM',
                'username' => 'rini_admin',
                'email'    => 'rini@admin.com',
                'jabatan'  => 'Kasi Informasi Pasar Kerja dan Analisis Produktivitas',
            ],
        ];

        foreach ($admins as $admin) {
            User::updateOrCreate(
                ['username' => $admin['username']],
                [
                    'name'     => $admin['name'],
                    'email'    => $admin['email'],
                    'password' => Hash::make('password123'),
                    'role'     => 'admin',
                    'jabatan'  => $admin['jabatan'],
                ]
            );
        }

        /*
        |--------------------------------------------------------------------------
        | USER / PEGAWAI
        |--------------------------------------------------------------------------
        | Dalam database role disimpan sebagai "user".
        | Di tampilan sistem boleh tetap ditulis sebagai "Pegawai".
        */
        $pegawai = [
            [
                'name'     => 'HARRI MULIAWAN, ST',
                'username' => 'hari_disnaker',
                'email'    => 'harri@pegawai.com',
                'jabatan'  => 'Pengawas Ketenagakerjaan Ahli Muda',
            ],
            [
                'name'     => 'DANA OKTAVIAN, S.Sos',
                'username' => 'dana_disnaker',
                'email'    => 'dana@pegawai.com',
                'jabatan'  => 'Pengawas Ketenagakerjaan Ahli Muda',
            ],
            [
                'name'     => 'LISBET MARYATI S, SH',
                'username' => 'lisbet_disnaker',
                'email'    => 'lisbet@pegawai.com',
                'jabatan'  => 'Pengawas Ketenagakerjaan Ahli Pertama',
            ],
            [
                'name'     => 'MAISA BAHARI, SH',
                'username' => 'maisa_disnaker',
                'email'    => 'maisa@pegawai.com',
                'jabatan'  => 'Pengawas Ketenagakerjaan Ahli Pertama',
            ],
            [
                'name'     => 'URAY NANDA KHARISMA, SE',
                'username' => 'uray_disnaker',
                'email'    => 'uray@pegawai.com',
                'jabatan'  => 'Pengawas Ketenagakerjaan Ahli Pertama',
            ],
        ];

        foreach ($pegawai as $user) {
            User::updateOrCreate(
                ['username' => $user['username']],
                [
                    'name'     => $user['name'],
                    'email'    => $user['email'],
                    'password' => Hash::make('password123'),
                    'role'     => 'user',
                    'jabatan'  => $user['jabatan'],
                ]
            );
        }
    }
}
