<?php

namespace Database\Seeders;

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

class ManagerUsersSeeder extends Seeder
{
    /**
     * Create one demo login per back-office role for testing RBAC.
     * All use the password "password".
     */
    public function run(): void
    {
        $accounts = [
            ['HR Officer', 'hr@hrpayroll.local', 'HR'],
            ['Bursary Officer', 'bursary@hrpayroll.local', 'BURSARY'],
            ['Auditor', 'auditor@hrpayroll.local', 'AUDITOR'],
        ];

        foreach ($accounts as [$name, $email, $role]) {
            $user = User::firstOrCreate(
                ['email' => $email],
                ['name' => $name, 'password' => Hash::make('password'), 'activated_at' => now()],
            );
            $user->syncRoles([$role]);
        }
    }
}
