hasValidSignature()) { abort(401); } $shipment = Shipment::findOrFail($shipment); $service = app(CarrierFulfillmentInterface::class, ['carrier' => $shipment->carrier]); // Manual carriers, typed-in vouchers and synced ones have no // carrier label to print. if (! $service || ! $shipment->hasCarrierLabel()) { abort(404); } $bytes = $service->printLabel($shipment); // Printing may have just issued the voucher number (ELTA pending // vouchers), so name the file after the refreshed record. $name = $shipment->refresh()->tracking_reference ?? $shipment->id; return response($bytes, 200, [ 'Content-Type' => 'application/pdf', 'Content-Disposition' => 'inline; filename="shipment-'.$name.'.pdf"', ]); } }