<?php

namespace App\Modules\HR\Recruitment\Requests;

use App\Modules\HR\Recruitment\Models\RecruitmentOfferLetter;
use Illuminate\Foundation\Http\FormRequest;

class StoreOfferLetterAttachmentRequest extends FormRequest
{
    public function authorize(): bool
    {
        $offer = $this->route('offer_letter');

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

    /** @return array<string, mixed> */
    public function rules(): array
    {
        return [
            'attachment' => ['required', 'file', 'max:10240'],
        ];
    }
}
