<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Schema;

class UserRoleSeeder extends Seeder
{
    /**
     * Jalankan seeder akun pengguna.
     */
    public function run(): void
    {
        Schema::disableForeignKeyConstraints();
        DB::table('users')->truncate();
        Schema::enableForeignKeyConstraints();

        $users = [
            [
                'name' => 'Dinas Pertanian Prov',
                'email' => 'admin.prov@jateng.go.id',
                'no_hp' => '081234567890',
                'role' => 'provinsi_admin',
                'regency_id' => null,
                'password' => Hash::make('password'),
                'is_active' => true,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'name' => 'Dr. H. Supriyono',
                'email' => 'kadin.prov@jateng.go.id',
                'no_hp' => '081222223333',
                'role' => 'provinsi_pejabat',
                'regency_id' => null,
                'password' => Hash::make('password'),
                'is_active' => true,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'name' => 'Admin Kab Demak',
                'email' => 'dinpertan.demak@demakkab.go.id',
                'no_hp' => '081345678901',
                'role' => 'kabupaten_user',
                'regency_id' => 1,
                'password' => Hash::make('password'),
                'is_active' => true,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'name' => 'Admin Kab Temanggung',
                'email' => 'dinpertan.temanggung@temanggungkab.go.id',
                'no_hp' => '081901234567',
                'role' => 'kabupaten_user',
                'regency_id' => 2,
                'password' => Hash::make('password'),
                'is_active' => true,
                'created_at' => now(),
                'updated_at' => now(),
            ],
        ];

        DB::table('users')->insert($users);
    }
}