@php $initialComponents = collect(old('components', isset($product) ? $product->components->map(fn ($component) => [ 'product_id' => $component->component_product_id, 'quantity' => (float) $component->quantity, ])->all() : [])); $initialComboMode = old('combo_mode', $product->combo_mode ?? 'direct'); $initialComboYield = old('combo_yield_quantity', $product->combo_yield_quantity ?? 1); $componentProductOptions = $componentProducts->map(function ($item) { return [ 'id' => $item->id, 'label' => $item->name.' | '.$item->barcode, 'name' => $item->name, 'barcode' => $item->barcode, 'cost' => (float) $item->buying_price, 'stock' => (float) $item->stock_quantity, ]; })->values()->all(); $initialComponentOptions = $initialComponents->values()->all(); @endphp