<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Carbon\Carbon;

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

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'reservation_date' => [
                'required',
                'date',
                'after:today',
            ],
            'full_name' => [
                'required',
                'string',
                'max:255',
            ],
            'number_of_persons' => [
                'required',
                'integer',
                'min:1',
                'max:50',
            ],
            'instagram_link' => [
                'required',
                'string',
                'max:255',
                'regex:/^https?:\/\/(www\.)?instagram\.com\/[a-zA-Z0-9._]+\/?$/',
            ],
            'id_head_image' => [
                'required',
                'image',
                'mimes:jpeg,png,jpg',
                'max:2048',
            ],
            'id_tail_image' => [
                'required',
                'image',
                'mimes:jpeg,png,jpg',
                'max:2048',
            ],
        ];
    }

    /**
     * Get custom messages for validator errors.
     *
     * @return array
     */
    public function messages(): array
    {
        return [
            'reservation_date.required' => 'The reservation date is required.',
            'reservation_date.after' => 'The reservation date must be after today.',
            'full_name.required' => 'The full name is required.',
            'number_of_persons.required' => 'The number of persons is required.',
            'number_of_persons.min' => 'The number of persons must be at least 1.',
            'number_of_persons.max' => 'The number of persons cannot exceed 50.',
            'instagram_link.required' => 'The Instagram link is required.',
            'instagram_link.regex' => 'Please enter a valid Instagram profile URL.',
            'id_head_image.required' => 'The ID head image is required.',
            'id_head_image.image' => 'The ID head image must be an image file.',
            'id_head_image.mimes' => 'The ID head image must be a JPEG, PNG, or JPG file.',
            'id_head_image.max' => 'The ID head image must not exceed 2MB.',
            'id_tail_image.required' => 'The ID tail image is required.',
            'id_tail_image.image' => 'The ID tail image must be an image file.',
            'id_tail_image.mimes' => 'The ID tail image must be a JPEG, PNG, or JPG file.',
            'id_tail_image.max' => 'The ID tail image must not exceed 2MB.',
        ];
    }

    /**
     * Get custom attributes for validator errors.
     *
     * @return array
     */
    public function attributes(): array
    {
        return [
            'reservation_date' => 'reservation date',
            'full_name' => 'full name',
            'number_of_persons' => 'number of persons',
            'instagram_link' => 'Instagram link',
            'id_head_image' => 'ID head image',
            'id_tail_image' => 'ID tail image',
        ];
    }
} 