hasValidSignature()) { abort(401); } $ids = array_filter(array_map('intval', explode(',', (string) $request->query('ids')))); $shipments = Shipment::whereIn('id', $ids)->orderBy('id')->get() ->filter(fn (Shipment $shipment) => $shipment->hasCarrierLabel()); $carriers = $shipments->pluck('carrier')->unique(); if ($shipments->isEmpty() || $carriers->count() !== 1) { abort(404); } $service = app(CarrierFulfillmentInterface::class, ['carrier' => $carriers->first()]); if (! $service instanceof SupportsBatchLabels) { abort(404); } return response($service->printLabels($shipments), 200, [ 'Content-Type' => 'application/pdf', 'Content-Disposition' => 'inline; filename="labels-'.now()->format('Ymd-His').'.pdf"', ]); } }