Search code examples
laravellaravel-5.1laravel-5qr-code

Qrcode in laravel


i want to make qrcode, in there i can make it but i have something trouble when i want to change the format of qrcode to png file. but its only show symbol

here my view :

<?php echo QrCode::size(265)->generate($row->id) ?>

this qrcode i use :

"simplesoftwareio/simple-qrcode": "~1"

here my referance : https://www.simplesoftware.io/docs/simple-qrcode

can anyone help me ? or can someone give me solution ? before i change format to png : this before i change format

and this after i change it : after i change it


Solution

  • If you are formatting it as png file format, you need to include it with a <img> tag.

    Taken from the documentation

    //Inside of a blade template.
    <img src="{!!$message->embedData(QrCode::format('png')->generate('Embed me into an e-mail!'), 'QrCode.png', 'image/png')!!}">
    

    You can also do this:

    $png = QrCode::format('png')->size(512)->generate(1);
    $png = base64_encode($png);
    echo "<img src='data:image/png;base64," . $png . "'>";