<?php

declare(strict_types=1);

namespace TechnoArtisan\FilamentCms\Http\Requests;

use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;

class ContactRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true; // public access
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        $requestOptions = array_keys(fcms__('content-contact.request_options'));
        unset($requestOptions[0]); // remove empty from an array

        return [
            'name'    => 'required|min:3|max:255',
            'email'   => 'required|email',
            'request' => 'required|in:' . implode(',', $requestOptions),
            'message' => 'required|min:10',
            'consent' => 'required',
        ];
    }
}
