Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Marko123's avatar

Help about QR Code

Hello guys, i first time write here and i think you can help me. My problem is that when I try to put in the barcode to automatically enter what is needed it doesn't do it but just overwrites the code, I've looked on a couple of pages and I can't find a solution to my problem anywhere.

Here is the thing i need to be automatically writed in qr code.

    <div class="col-40">
        <div class="text p-index-right">
            @stack('document_number_input_start')
                @if (! $hideDocumentNumber)
                    <p class="mb-0">
                        <span class="font-semibold w-numbers">
                        <strong> OTPREMNICA - FAKTURA</strong>
                        </span>

                        <span class="float-right spacing">
                            {{ $document->document_number }}
                        </span>
                    </p>
                @endif
            @stack('document_number_input_end')

Here is the code of qrcode

        @stack('barcode_input_start')
            <div class="container-barcod">
                <div class="card qrcode">
                    <div class="card-body">
                    {!! QrCode::encoding('UTF-8')->generate('S:Plaćanje racuna {{$document_number}}') !!}
                    </div>
                </div>
            </div>
        @stack('barcode_input_end')

Here is the screenshot of what i get when scan qrcode https://imgur.com/QnNK5yL I need the document_number to be written there, which will be set by itself when I create the invoice.

0 likes
29 replies
OriOn's avatar

Hello, you are using a blade echo statement {{ }} inside another one (the escaped one {!! !!}) You probably need to update your QrCode generate argument from

QrCode::encoding('UTF-8')->generate('S:Plaćanje racuna {{$document_number}}')

To

QrCode::encoding('UTF-8')->generate('S:Plaćanje racuna ' . $document_number)
Sinnbeck's avatar

@Marko123 did you remove the outer {} as well?

{!! QrCode::encoding('UTF-8')->generate('S:Plaćanje racuna ' . $document_number) !!}
Marko123's avatar

@Sinnbeck Yes i try to remove and when i remove i got error and script crash, when i start witout {!! !!} i got only text not qr code

Sinnbeck's avatar

@Marko123 look at the red error. There is link there with localhost etc. Click that (or right click and open in new tab). If it doesn't work, just type it into the browser url bar :)

Sinnbeck's avatar

@Marko123 you are going to file:// instead of http:// try clicking on the link I provided

Sinnbeck's avatar

@Marko123 did you turn off APP_DEBUG in your env file? You should see the actual error

Sinnbeck's avatar

@Marko123 there you go. You haven't passed $document_number to the view it seems :) where do you set this variable?

Sinnbeck's avatar

@Marko123 ah not quite the same.

{!! QrCode::encoding('UTF-8')->generate('S:Plaćanje racuna ' . $document->document_number) !!}

See the difference?

Marko123's avatar

@Sinnbeck Yes,yes,yes omg thank you so much i like 2 day hiting my head and dont know what is problem hahaha, thank you so much. And one more ask can i now make like this

{!! QrCode::encoding('UTF-8')->generate('K:PR|V:01|C:1|R:265163031000681831|N:Ljubiša Jevtić PR proizvodnja i prodaja kolača Olgica T&M Slanci|I:RSD'.$document->amount_due'|P:Podatci o platiocu|SF:221|S:Plaćanje racuna' . $document->document_number ) !!}

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@Marko123 hmm I would assume it would convert it correctly. Try this perhaps

{!! QrCode::encoding('UTF-8')->generate("S:Plaćanje racuna{$document->document_number}") !!}
1 like
Marko123's avatar

@Sinnbeck Its working, thank you so much. Can i ask you here about number to word problem what i have or i need to crate new thread with other name?

Sinnbeck's avatar

@Marko123 please create a new thread. It will make it easier for others to help as well

1 like

Please or to participate in this conversation.