Search code examples
phplaravelenvironment-variablesglobal-variables

How to make one word univeral variable in Laravel


I do not know if it is logical or not,

I want to make a varibale say @ads in view files wherever I put @ads

It would call specific div element:

<div class="ads">
@if(condition)
 some block of codes...
@endif
</div>

which is defined for @ads. is it possible? if yes how?


Solution

  • You're free to use the @include directive :

    @if(condition)
        @include('ads')
    @endif
    

    It will include the blade view from ads.blade.php