<?php

namespace Database\Seeders;

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

class UserSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        // Créer Super Administrateur
        $superAdmin = User::create([
            'matricule' => 'ADMIN001',
            'full_name' => 'Super Administrateur',
            'email' => 'admin@hospital.com',
            'phone' => '0123456789',
            'address' => 'Hôpital Psychiatrique de Bingerville',
            'gender' => 'Masculin',
            'fonction' => 'Super Administrateur',
            'service' => 'Administration',
            'date_of_hiring' => now()->subYears(5),
            'password' => Hash::make('password'),
            'email_verified_at' => now(),
        ]);
        $superAdmin->assignRole('Super Administrateur');

        // Créer Administrateur
        $admin = User::create([
            'matricule' => 'ADMIN002',
            'full_name' => 'Administrateur',
            'email' => 'admin2@hospital.com',
            'phone' => '0123456790',
            'address' => 'Hôpital Psychiatrique de Bingerville',
            'gender' => 'Masculin',
            'fonction' => 'Administrateur',
            'service' => 'Administration',
            'date_of_hiring' => now()->subYears(3),
            'password' => Hash::make('password'),
            'email_verified_at' => now(),
        ]);
        $admin->assignRole('Administrateur');

        // Créer Magasinier
        $magasinier = User::create([
            'matricule' => 'MAG001',
            'full_name' => 'Jean Magasinier',
            'email' => 'magasinier@hospital.com',
            'phone' => '0123456791',
            'address' => 'Hôpital Psychiatrique de Bingerville',
            'gender' => 'Masculin',
            'fonction' => 'Magasinier',
            'service' => 'Logistique',
            'date_of_hiring' => now()->subYears(2),
            'password' => Hash::make('password'),
            'email_verified_at' => now(),
        ]);
        $magasinier->assignRole('Magasinier');

        // Créer Responsable du département
        $responsable = User::create([
            'matricule' => 'RESP001',
            'full_name' => 'Marie Kouassi',
            'email' => 'responsable@hospital.com',
            'phone' => '0123456792',
            'address' => 'Hôpital Psychiatrique de Bingerville',
            'gender' => 'Feminin',
            'fonction' => 'Responsable du département',
            'service' => 'Département Médical',
            'date_of_hiring' => now()->subYears(4),
            'password' => Hash::make('password'),
            'email_verified_at' => now(),
        ]);
        $responsable->assignRole('Responsable du département');

        $this->command->info('Utilisateurs créés avec succès !');
        $this->command->info('Super Admin: ADMIN001 / password');
        $this->command->info('Admin: ADMIN002 / password');
        $this->command->info('Magasinier: MAG001 / password');
        $this->command->info('Responsable du département: RESP001 / password');
    }
}
