<?php

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

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'supplier_name' => 'nullable|string|max:255',
            'supplier_contact' => 'nullable|string|max:255',
            'expected_at' => 'nullable|date',
            'notes' => 'nullable|string',
            'items' => 'nullable|array',
            'items.*.ingredient_id' => 'required_with:items|exists:ingredients,id',
            'items.*.quantity_ordered' => 'required_with:items|numeric|min:0.0001',
            'items.*.unit_cost' => 'required_with:items|numeric|min:0',
        ];
    }
}
