<?php

namespace App\Modules\HR\Recruitment\Requests;

use App\Modules\HR\Recruitment\Models\RecruitmentApplication;
use App\Modules\HR\Recruitment\Support\ApplicationStatus;
use Illuminate\Validation\Rule;

class UpdateApplicationRequest extends StoreApplicationRequest
{
    public function authorize(): bool
    {
        $row = $this->route('application');

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

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