<?php

namespace App\Http\Requests\InventoryItems;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'name' => ['sometimes', 'required', 'string', 'max:255'],
            'sku' => ['sometimes', 'nullable', 'string', 'max:255'],
            'unit' => ['sometimes', 'required', 'string', 'max:50'],
            'stock_quantity' => ['sometimes', 'nullable', 'numeric', 'min:0'],
            'min_alert' => ['sometimes', 'nullable', 'numeric', 'min:0'],
            'critical_alert' => ['sometimes', 'nullable', 'numeric', 'min:0'],
            'cost_per_unit_crc' => ['sometimes', 'nullable', 'numeric', 'min:0'],
            'is_active' => ['sometimes', 'nullable', 'boolean'],
            'category' => ['sometimes', 'nullable', 'string', 'max:255'],
            'meta' => ['sometimes', 'nullable', 'array'],
            'meta.feed_type' => ['sometimes', 'nullable', 'string', 'max:10'],
            'meta.supplier' => ['sometimes', 'nullable', 'string', 'max:255'],
            'meta.notes' => ['sometimes', 'nullable', 'string', 'max:2000'],
            'meta.package_cost_crc' => ['sometimes', 'nullable', 'numeric', 'min:0'],
            'meta.package_quantity' => ['sometimes', 'nullable', 'numeric', 'min:0'],
        ];
    }
}
