<?php

namespace Database\Seeders;

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

class UsersTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $superAdminRole = Role::firstOrCreate(['name' => 'super_admin'], ['display_name' => 'SuperAdministrador']);
        $adminRole = Role::firstOrCreate(['name' => 'admin'], ['display_name' => 'Administrador']);
    
        
        $superadmin = User::firstOrCreate(
            ['email' => 'canalla.agency@gmail.com'],
            [
                'name' => 'SuperAdmin',
                'password' => Hash::make('@#AdminDev2024#')
            ]
        );

        $admin = User::firstOrCreate(
            ['email' => 'aldair.canalla.agency@gmail.com'],
            [
                'name' => 'Aldair Reyes Sánchez',
                'password' => Hash::make('aldair123')
            ]
        );

        $superadmin->roles()->syncWithoutDetaching([$superAdminRole->id]);

        $admin->roles()->syncWithoutDetaching([$adminRole->id]);
    }
}
