<?php

namespace App\Http\Requests\Rooms;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Str;
use Illuminate\Validation\Rule;

class RoomUpdateRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }
    /**
     * @return void
     */
    protected function prepareForValidation(): void
    {
        $this->merge([
            'slug' => Str::slug($this->input('title_az')),
            'show_in_main' => $this->has('show_in_main')
        ]);
    }

    /**
     * @return string[]
     */
    public function rules(): array
    {
        return [
            'slug' => ['nullable', 'string', 'max:200'],
            'category_id' => ['nullable', 'numeric','min:1'],
            'title_az' => ['nullable', 'string', 'max:200'],
            'title_ru' => ['nullable', 'string', 'max:200'],
            'title_en' => ['nullable', 'string', 'max:200'],
            'price' => ['nullable', 'string', 'max:200'],
            'description_az' => ['nullable'],
            'description_ru' => ['nullable'],
            'description_en' => ['nullable'],
            'image' => ['nullable', 'file', 'image' ,'mimes:jpeg,png,jpg,gif,webp,svg,heic'],
            'video' => 'nullable|mimes:mp4,mov,ogg,qt',
            'show_in_main' => ['sometimes','boolean'],
            'partners.*' => ['nullable', 'file', 'image', 'mimes:jpeg,png,jpg,gif,webp,svg,heic'] 

        ];
    }
}
