<?php

namespace App\Modules\HR\Leave\Requests;

use App\Modules\HR\Leave\Models\LeaveType;

class UpdateLeaveTypeRequest extends StoreLeaveTypeRequest
{
    public function authorize(): bool
    {
        $type = $this->route('leave_type');

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

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