feat: Attach QR sticker PDF to Trello card on order creation

When a new order is created and a Trello card is made, now automatically
generate the A6 QR sticker PDF and attach it to the card using Trello's
attachment API. Include error handling and logging.
This commit is contained in:
twotalesanimation
2026-01-02 21:01:17 +02:00
parent 93148ef9af
commit ed57956694
3 changed files with 62 additions and 47 deletions
+7 -11
View File
@@ -116,7 +116,7 @@ Route::match(['get', 'post'], '/test/sticker/{orderNumber}/regenerate', function
$order = \App\Models\Order::where('order_number', $orderNumber)->first();
if (!$order) {
return response()->json(['error' => 'Order not found'], 404);
return response('Order not found', 404);
}
try {
@@ -131,18 +131,14 @@ Route::match(['get', 'post'], '/test/sticker/{orderNumber}/regenerate', function
$service = new \App\Services\QrStickerService();
$paths = $service->generateSticker($order);
return response()->json([
'success' => true,
'message' => 'Sticker PDF generated successfully',
'svg_path' => $paths['svg_path'],
'pdf_path' => $paths['pdf_path'],
'view_url' => route('test.sticker', ['orderNumber' => $orderNumber])
// Return PDF inline for viewing
$pdfPath = storage_path('app/public/' . $paths['pdf_path']);
return response()->file($pdfPath, [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="QR-' . $order->order_number . '.pdf"'
]);
} catch (\Exception $e) {
return response()->json([
'error' => 'Failed to generate sticker',
'message' => $e->getMessage()
], 500);
return response('Failed to generate sticker: ' . $e->getMessage(), 500);
}
})->name('test.sticker.regenerate');