diff --git a/composer.json b/composer.json index 7bf79c5..f0c8c72 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,6 @@ "require": { "php": ">=8.0", "awssat/laravel-visits": "^6.0", - "bacon/bacon-qr-code": "^2.0", "codedge/laravel-selfupdater": "^3.6", "cohensive/oembed": "^0.17", "doctrine/dbal": "^3.0", @@ -20,6 +19,7 @@ "laravel/tinker": "^2.5", "livewire/livewire": "^2.12", "rappasoft/laravel-livewire-tables": "^2.15", + "simplesoftwareio/simple-qrcode": "~4", "spatie/laravel-backup": "^8.17" }, "require-dev": { diff --git a/resources/views/layouts/sidebar.blade.php b/resources/views/layouts/sidebar.blade.php index 74ad3c4..5b808c3 100755 --- a/resources/views/layouts/sidebar.blade.php +++ b/resources/views/layouts/sidebar.blade.php @@ -1,9 +1,5 @@ @php -use BaconQrCode\Renderer\ImageRenderer; -use BaconQrCode\Renderer\Image\ImagickImageBackEnd; -use BaconQrCode\Renderer\RendererStyle\RendererStyle; -use BaconQrCode\Writer; -use BaconQrCode\Renderer\Image\SvgImageBackEnd; +use SimpleSoftwareIO\QrCode\Facades\QrCode; use App\Models\User; $usrhandl = Auth::user()->littlelink_name; @endphp @@ -685,33 +681,57 @@ $usrhandl = Auth::user()->littlelink_name; @php try { - $qrCodeData = url('@'.Auth::user()->littlelink_name); + $redirectURL = url('').'/'.'u/'.Auth::user()->id; - $renderer = new ImageRenderer( - new RendererStyle(400), - new SvgImageBackEnd() - ); - $writer = new Writer($renderer); + if (extension_loaded('imagick')) { + $imgSrc = QrCode::format('png')->size(1000)->generate($redirectURL); + $imgSrc = base64_encode($imgSrc); + $imgSrc = 'data:image/png;base64,' . $imgSrc; + $imgType = 'png'; + } else { + $imgSrc = QrCode::size(1000)->generate($redirectURL); + $imgSrc = base64_encode($imgSrc); + $imgSrc = 'data:image/svg+xml;base64,' . $imgSrc; + $imgType = 'svg'; + } - $svgImageData = $writer->writeString($qrCodeData); - - $svgImageBase64 = base64_encode($svgImageData); - - $imgSrc = 'data:image/svg+xml;base64,' . $svgImageBase64; - } catch(exception $e) {echo '
{{__("messages.QR code could not be generated")}}
'; if(auth()->user()->role == 'admin'){echo "{{__('messages.Reason:')}}
".$e->getMessage()."";}} + } catch(exception $e) { + $imgSrc = url('/assets/linkstack/images/themes/no-preview.png'); + $imgType = NULL; + } @endphp