<?php

namespace App\Http\Requests\Recipes;

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

class UpdateRecipeRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'slug' => [
                'sometimes',
                'required',
                'string',
                'max:255',
                Rule::unique('recipes', 'slug')->ignore($this->route('recipe')),
            ],
            'title' => ['sometimes', 'required', 'string', 'max:255'],
            'description' => ['sometimes', 'nullable', 'string'],
            'image_url' => ['sometimes', 'nullable', 'string', 'max:2048'],
            'ingredients' => ['sometimes', 'nullable', 'array'],
            'steps' => ['sometimes', 'nullable', 'array'],
            'time_minutes' => ['sometimes', 'nullable', 'integer', 'min:0'],
            'difficulty' => ['sometimes', 'nullable', 'string', 'max:50'],
            'tags' => ['sometimes', 'nullable', 'array'],
        ];
    }
}
