<?php

namespace App\Http\Requests\InventoryItems;

use Illuminate\Foundation\Http\FormRequest;

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

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