<?php

namespace Database\Seeders;

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

class RoleSeeder extends Seeder
{
    public function run(): void
    {
        // 1. Crear Roles si no existen
        $superAdminRole = Role::create(['name' => 'superadmin']);
        $adminRole      = Role::create(['name' => 'admin']);
        $userRole       = Role::create(['name' => 'usuario']);

        // 2. Crear un usuario Superadmin de prueba
        $superAdmin = User::create([
            'name' => 'Super Administrador',
            'email' => 'superadmin@adipa.cl',
            'password' => Hash::make('password123'), // Cambia esto en producción
        ]);
        // Asignar el rol
        $superAdmin->assignRole($superAdminRole);

        // 3. Crear un Admin de prueba
        $admin = User::create([
            'name' => 'Admin Académico',
            'email' => 'admin@adipa.cl',
            'password' => Hash::make('password123'),
        ]);
        $admin->assignRole($adminRole);
    }
}