Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Dompdf image generation with if else statement in Laravel 9

I’m studying DOMpdf. I can display images but when I add if else statement
the function doesn’t work and I always got this error image.

@if ($student->w2c = '')
no image.
@else
// w2c is ture or false alwasy got error image as attach file
<img src="data:image/png;base64, {{ $w2_img }}" width="100%"
class="img-thumbnail">
@endif

but somehow same PDF generate blade file not image if else statement works fine.

@if ($student->br = 'area1')
area1 info
@elseif ($student->br = 'area2')
area2 info
@else
-
@endif

Could someone teach me please?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

>Solution :

You need to use == or === when you compare the values. It should be:

@if ($student->w2c == '')
no image.
@else
// w2c is ture or false alwasy got error image as attach file
<img src="data:image/png;base64, {{ $w2_img }}" width="100%"
class="img-thumbnail">
@endif

Reference more https://www.php.net/manual/en/language.operators.comparison.php

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading