<?php

namespace Modules\HR\Database\Seeders;

use Illuminate\Database\Seeder;
use Modules\Auth\Models\Role;
use Modules\Core\Enums\RolesEnum;
use Modules\Core\Traits\HasModulePermissions;

class HrPermissionSeeder extends Seeder
{
    use HasModulePermissions;

    public function run(): void
    {
        $this->seedPermissions('hr', [
            'setting' => [
                'view',
                'manage',
            ],

            'salary-revision-status' => [
                'applied',
                'approved',
            ],

            'overtime-entry' => [
                'approved',
            ],

            'holiday-allowances' => [
                'approved',
            ],

        ]);

        Role::where('name', RolesEnum::ADMIN->value)->first()?->givePermissionTo([
            'hr.setting.view',
            'hr.setting.manage',
            'hr.overtime-entry.approved',
            'hr.holiday-allowances.approved',
            'hr.salary-revision-status.applied',
        ]);

        Role::where('name', RolesEnum::HR->value)->first()?->givePermissionTo([
            'hr.setting.view',
            'hr.setting.manage',

        ]);

        Role::where('name', RolesEnum::ACCOUNTS->value)->first()?->givePermissionTo([
            'hr.setting.view',

            'hr.salary-revision-status.approved'
        ]);
    }
}
