<?php

namespace Database\Seeders;

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

class UserSeeder extends Seeder
{
    public function run(): void
    {
        $user = User::updateOrCreate(
            ['email' => 'ammar@dinaslhdki.id'],
            [
                'name' => 'Ammar',
                'username' => 'ammar',
                'password' => Hash::make('Muammar123$'),
            ]
        );

        // Assign DLH (super admin) role
        $user->syncRoles(['DLH']);

        // Kadis user
        $kadis = User::updateOrCreate(
            ['email' => 'kadis@dinaslhdki.id'],
            [
                'name' => 'Kadis',
                'username' => 'kadis',
                'password' => Hash::make('Perling2025$'),
            ]
        );
        $kadis->syncRoles(['Kadis']);

        // Perusahaan user
        $perusahaan = User::updateOrCreate(
            ['email' => 'perusahaan@dinaslhdki.id'],
            [
                'name' => 'Perusahaan',
                'username' => 'perusahaan',
                'password' => Hash::make('Perling2025$'),
            ]
        );
        $perusahaan->syncRoles(['Perusahaan']);

        // PPKL user (note: domain as provided)
        $ppkl = User::updateOrCreate(
            ['email' => 'ppkl@dinaslhkdki.id'],
            [
                'name' => 'PPKL',
                'username' => 'ppkl',
                'password' => Hash::make('Perling2025$'),
            ]
        );
        $ppkl->syncRoles(['PPKL']);
    }
}
