<?php

namespace Database\Seeders;

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

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     */
    public function run(): void
    {
        // Roles & permissions first, so users can be assigned roles.
        $this->call(RolesAndPermissionsSeeder::class);

        // Initial system administrator.
        $admin = User::firstOrCreate(
            ['email' => 'admin@hrpayroll.local'],
            ['name' => 'System Administrator', 'password' => Hash::make('password')]
        );
        $admin->assignRole('ADMIN');

        // Reference/lookup data for employee-form dropdowns.
        $this->call(MasterDataSeeder::class);

        // PAYE ruleset (CRA + bands + minimum tax).
        $this->call(TaxTableSeeder::class);

        // Tax-exempt relief components (NHIS, life assurance).
        $this->call(ReliefComponentsSeeder::class);
    }
}
