<?php

namespace App\Modules\HR\Payroll\Requests;

use App\Modules\HR\Payroll\Models\SalaryStructure;

class UpdateSalaryStructureRequest extends StoreSalaryStructureRequest
{
    public function authorize(): bool
    {
        $structure = $this->route('salary_structure');

        return $structure instanceof SalaryStructure
            && ($this->user()?->can('update', $structure) ?? false);
    }

    /**
     * @return array<string, mixed>
     */
    public function rules(): array
    {
        return array_merge(parent::rules(), [
            'is_active' => ['required', 'boolean'],
        ]);
    }
}
