<?php

namespace App\Http\Requests\Api\V1\Recipe;

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

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

    public function rules(): array
    {
        return [
            'name' => 'sometimes|string|max:255',
            'sku' => ['sometimes', 'string', 'max:255', Rule::unique('ingredients', 'sku')->ignore($this->route('id'))],
            'unit' => 'sometimes|string|max:50',
            'cost_per_unit' => 'nullable|numeric|min:0',
            'minimum_stock' => 'nullable|numeric|min:0',
            'reorder_level' => 'nullable|numeric|min:0',
            'is_active' => 'boolean',
        ];
    }
}
