<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class RoomCategoryRequest 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 [
            'short_name' => 'required|string|max:255',
            'name' => 'required|string|max:255',
            'slug' => 'required|string|max:255|unique:room_categories,slug,' . $this->room_category?->id,
            'sort_order' => 'required|integer|min:0',
            'description' => 'required|string',
            'details' => 'nullable|string',
            'policies' => 'nullable|string',

            'base_price' => 'required|numeric|min:0',

            'max_adults' => 'nullable|integer|min:1',
            'max_children' => 'nullable|integer|min:0',
            'default_bed_count' => 'nullable|integer|min:1',
            'default_bathroom_count' => 'nullable|integer|min:1',
            'default_size' => 'nullable|integer|min:1',

            'is_published' => 'nullable|boolean',

            'images' => 'nullable|array',
            'images.*.id' => 'required|exists:images,id',
            'images.*.role' => 'required|string',
            'images.*.sort_order' => 'required|integer',

            'facilities' => 'nullable|array',
            'meal_packages' => 'nullable|array',
            'add_ons' => 'nullable|array',
        ];
    }
}
