<?php

namespace App\Http\Requests\Projects;

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

class ProjectUpdateRequest 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')),
        ]);
    }

    /**
     * @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'],
            'option' => ['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'],
        ];
    }
}
