<?php

namespace App\Modules\HR\Recruitment\Requests;

use Illuminate\Foundation\Http\FormRequest;

class UpdateVacancyPortalMetaRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()?->can('recruitment.manage') ?? false;
    }

    /** @return array<string, mixed> */
    public function rules(): array
    {
        return [
            'seo_title' => ['nullable', 'string', 'max:180'],
            'seo_description' => ['nullable', 'string', 'max:320'],
            'seo_keywords' => ['nullable', 'string', 'max:255'],
            'is_featured' => ['nullable', 'boolean'],
        ];
    }

    protected function prepareForValidation(): void
    {
        $this->merge([
            'is_featured' => $this->boolean('is_featured'),
        ]);
    }
}
