shippingAddress?->shipping_option; $method = $code ? ShippingMethod::where('code', $code)->first() : null; return Shipment::create([ 'order_id' => $order->id, 'carrier' => 'manual', 'source' => Shipment::SOURCE_MANUAL, 'tracking_reference' => filled($request->trackingReference) ? trim($request->trackingReference) : null, 'meta' => [ 'carrier_name' => $method?->data['carrier_name'] ?? null, 'tracking_url' => $method?->data['tracking_url'] ?? null, 'package_count' => $request->packageCount, 'weight' => $request->weight, 'cod_amount' => $request->paymentMode === 'cod' ? (float) ($request->amountToCollect ?? $order->total->decimal) : null, ], ]); } public function printLabel(Shipment $shipment): string { throw new RuntimeException('Manual carriers have no printable label.'); } public function cancelShipment(Shipment $shipment): void { $shipment->update(['cancelled_at' => now()]); } }