From e503cd3479a028592a6b6d974f937ea085e7a600 Mon Sep 17 00:00:00 2001 From: twotalesanimation <80506065+twotalesanimation@users.noreply.github.com> Date: Fri, 2 Jan 2026 20:10:06 +0200 Subject: [PATCH] fix: Correct web.php syntax and use correct QR library - Fix malformed route on line 84 (missing closing paren and semicolon) - Replace SimpleSoftwareIO QrCode with chillerlan/php-qrcode (already installed) - Update QrStickerService to use chillerlan\QRCode\QRCode - Configure QR options for SVG output with H error correction --- app/Services/QrStickerService.php | 31 ++++++++++++++++++++++--------- routes/web.php | 5 +++-- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/app/Services/QrStickerService.php b/app/Services/QrStickerService.php index 9819f6d..25cf4c0 100644 --- a/app/Services/QrStickerService.php +++ b/app/Services/QrStickerService.php @@ -4,9 +4,10 @@ namespace App\Services; use App\Models\Order; use Barryvdh\DomPDF\Facade\Pdf; +use chillerlan\QRCode\QRCode; +use chillerlan\QRCode\QROptions; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Storage; -use SimpleSoftwareIO\QrCode\Facades\QrCode; class QrStickerService { @@ -56,12 +57,18 @@ class QrStickerService */ private function generateSvg(Order $order, string $qrUrl): string { - $qrCode = QrCode::size(300) - ->errorCorrection('H') - ->generate($qrUrl); + $options = new QROptions([ + 'outputType' => QRCode::OUTPUT_MARKUP_SVG, + 'eccLevel' => QRCode::ECC_H, + 'scale' => 3, + 'imageBase64' => false, + ]); + + $qrCode = new QRCode($options); + $qrSvg = $qrCode->render($qrUrl); $path = "qr-codes/{$order->uuid}.svg"; - Storage::disk('public')->put($path, $qrCode); + Storage::disk('public')->put($path, $qrSvg); return $path; } @@ -76,10 +83,16 @@ class QrStickerService */ private function generatePdf(Order $order, string $qrUrl): string { - // Generate inline QR code as base64 data URL - $qrSvg = QrCode::size(400) - ->errorCorrection('H') - ->generate($qrUrl); + // Generate inline QR code as SVG + $options = new QROptions([ + 'outputType' => QRCode::OUTPUT_MARKUP_SVG, + 'eccLevel' => QRCode::ECC_H, + 'scale' => 4, + 'imageBase64' => false, + ]); + + $qrCode = new QRCode($options); + $qrSvg = $qrCode->render($qrUrl); // Determine order type and format label $orderType = $order->type === 'standard' diff --git a/routes/web.php b/routes/web.php index e44417a..37b28b6 100644 --- a/routes/web.php +++ b/routes/web.php @@ -78,11 +78,11 @@ Route::middleware('auth')->group(function () { Route::post('/ops/orders/{order:uuid}/inspection-passed', [OpsController::class, 'markInspectionPassed'])->name('ops.order.inspection-passed'); Route::post('/ops/orders/{order:uuid}/inspection-failed', [OpsController::class, 'flagInspectionIssue'])->name('ops.order.inspection-failed'); Route::get('/ops/orders/{order:uuid}/sticker/download', [OpsController::class, 'downloadSticker'])->name('ops.order.sticker.download'); + Route::post('/custom-orders/{customOrder:uuid}/ship', [ShippingController::class, 'createShipment'])->name('custom-orders.ship'); }); // QR landing page (public but token-gated) -Route::get('/ops/orders/{token}', [OpsController::class, 'showOrder'])->name('ops.order.show' Route::post('/custom-orders/{customOrder:uuid}/ship', [ShippingController::class, 'createShipment'])->name('custom-orders.ship'); -}); +Route::get('/ops/orders/{token}', [OpsController::class, 'showOrder'])->name('ops.order.show'); // use Illuminate\Support\Facades\Route; @@ -94,5 +94,6 @@ Route::get('/font-test', function () { }); + // Test route for invoice generation (remove in production) require __DIR__ . '/test-invoice.php';