Skip to content
Advertisement

check in blade if exists variable in @include

I´m developping a system with laravel 7.4 and i need check if one variable that i´m sending from my controller exists in my blade. If exists, include it:

I have this code in my controller:

JavaScript

this return profile image or system image but it´s possible that this images don´t exists and i need check before, because i have error in my system and i can´t show my view.

Whit this code in my view after, i created a image with this route:

JavaScript

But previously i need send this variable ton my view head and after to my sidebar.

i´m traying to do this:

home.blade.php

JavaScript

head.blade.php

JavaScript

and in my sidebar created my image:

JavaScript

UPDATED

now i have this error:

in my head.blade.php i have this:

JavaScript

in my home.blade.php i have this

JavaScript

this return:

JavaScript

i need to do, that if table media is empty, load image for deafult, but if table media have logo or image system, load this images

Advertisement

Answer

you can use if condition

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement