<?php

namespace Database\Seeders;

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

class AdminUserSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        // Verificar si ya existe un usuario admin
        $exists = User::where('usuario', 'admin')->exists();

        if (!$exists) {
            User::create([
                'nombres' => 'Administrador',
                'apellidos' => 'del Sistema',
                'usuario' => 'admin',
                'clave' => Hash::make('Admin123!'),
                'rol' => 'ADMIN',
                'estado' => 1,
                'must_change_password' => false,
            ]);
        }
    }
}