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
This commit is contained in:
@@ -4,9 +4,10 @@ namespace App\Services;
|
|||||||
|
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
use Barryvdh\DomPDF\Facade\Pdf;
|
use Barryvdh\DomPDF\Facade\Pdf;
|
||||||
|
use chillerlan\QRCode\QRCode;
|
||||||
|
use chillerlan\QRCode\QROptions;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
|
||||||
|
|
||||||
class QrStickerService
|
class QrStickerService
|
||||||
{
|
{
|
||||||
@@ -56,12 +57,18 @@ class QrStickerService
|
|||||||
*/
|
*/
|
||||||
private function generateSvg(Order $order, string $qrUrl): string
|
private function generateSvg(Order $order, string $qrUrl): string
|
||||||
{
|
{
|
||||||
$qrCode = QrCode::size(300)
|
$options = new QROptions([
|
||||||
->errorCorrection('H')
|
'outputType' => QRCode::OUTPUT_MARKUP_SVG,
|
||||||
->generate($qrUrl);
|
'eccLevel' => QRCode::ECC_H,
|
||||||
|
'scale' => 3,
|
||||||
|
'imageBase64' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$qrCode = new QRCode($options);
|
||||||
|
$qrSvg = $qrCode->render($qrUrl);
|
||||||
|
|
||||||
$path = "qr-codes/{$order->uuid}.svg";
|
$path = "qr-codes/{$order->uuid}.svg";
|
||||||
Storage::disk('public')->put($path, $qrCode);
|
Storage::disk('public')->put($path, $qrSvg);
|
||||||
|
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
@@ -76,10 +83,16 @@ class QrStickerService
|
|||||||
*/
|
*/
|
||||||
private function generatePdf(Order $order, string $qrUrl): string
|
private function generatePdf(Order $order, string $qrUrl): string
|
||||||
{
|
{
|
||||||
// Generate inline QR code as base64 data URL
|
// Generate inline QR code as SVG
|
||||||
$qrSvg = QrCode::size(400)
|
$options = new QROptions([
|
||||||
->errorCorrection('H')
|
'outputType' => QRCode::OUTPUT_MARKUP_SVG,
|
||||||
->generate($qrUrl);
|
'eccLevel' => QRCode::ECC_H,
|
||||||
|
'scale' => 4,
|
||||||
|
'imageBase64' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$qrCode = new QRCode($options);
|
||||||
|
$qrSvg = $qrCode->render($qrUrl);
|
||||||
|
|
||||||
// Determine order type and format label
|
// Determine order type and format label
|
||||||
$orderType = $order->type === 'standard'
|
$orderType = $order->type === 'standard'
|
||||||
|
|||||||
+3
-2
@@ -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-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::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::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)
|
// 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;
|
// use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
@@ -94,5 +94,6 @@ Route::get('/font-test', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Test route for invoice generation (remove in production)
|
// Test route for invoice generation (remove in production)
|
||||||
require __DIR__ . '/test-invoice.php';
|
require __DIR__ . '/test-invoice.php';
|
||||||
|
|||||||
Reference in New Issue
Block a user