Ad

I Don’t Understand How @if Statements Work In Laravel Blade

- 1 answer

I started learn Laravel and ran into an @if statements problem. How must I write a condition for empty places of code so that it is correct?

@if( !Request::is('coming-soon') )

@elseif( !Request::is('error') )

@else
    @include('layouts.includes.header.main-menu')
@endif

I don't need this view in 'coming-soon' and 'error' pages.

Ad

Answer

You are doing it opposite:

I hope this is what you are looking for

@if( !Request::is('coming-soon') && !Request::is('error') )
    @include('layouts.includes.header.main-menu')
@endif

This will include the page if the requested url is not "coming-soon" or "error".

Ad
source: stackoverflow.com
Ad