@php $prefillLines = []; if ($prefillPo) { $po = $orders->firstWhere('po_no', $prefillPo); if ($po) { $prefillLines = $po->lines->map(fn ($l) => [ 'item' => $l->item, 'expected_qty' => $l->qty, 'received_qty' => $l->qty, 'unit' => $l->unit, 'unit_cost' => $l->unit_price, 'condition' => 'Good', 'notes' => '', ])->all(); } } $seed = old('lines', $prefillLines ?: [['item' => '', 'expected_qty' => 0, 'received_qty' => 1, 'unit' => '', 'unit_cost' => '', 'condition' => 'Good', 'notes' => '']]); @endphp