<?php

namespace Modules\Employee\Database\Seeders;

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

class EmployeePermissionSeeder extends Seeder
{
    use HasModulePermissions;

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

            'employee' => [
                'view',
                'create',
                'update',
                'delete',
                'status',
                'create-login',
            ],
        ]);

        Role::where('name', RolesEnum::ADMIN->value)->first()?->givePermissionTo([
            'employees.setting.view',
            'employees.setting.manage',
            'employees.employee.view',
            'employees.employee.create',
            'employees.employee.update',
            'employees.employee.delete',
            'employees.employee.status',
            'employees.employee.create-login',
        ]);

        Role::where('name', RolesEnum::HR->value)->first()?->givePermissionTo([
            'employees.employee.view',
            'employees.employee.create',
            'employees.employee.update',
            'employees.employee.status',
            'employees.employee.create-login',
        ]);
    }
}
