Reuben Wedson
Reuben Wedson

Reputation: 69

How do you check two conditions for current route laravel 5.7 blade template?

Im trying to pass a condition with a logical OR on blade view where I can display a div tag, Whenever either of the two conditions becomes true.

@if(\Route::current()->getName() != 'this_route' or \Route::current()->getName() != 'other_route')
      <div>Display when is true</div>
    @endif 

OR

@if(\Route::current()->getName() != 'this_route' || \Route::current()->getName() != 'other_route')
          <div>Display when is true</div>
        @endif

Both above codes do not work for me

Upvotes: 1

Views: 423

Answers (1)

Dilip Hirapara
Dilip Hirapara

Reputation: 15316

It should be && condition because as you said if both condition true then both parts should be executed then here you need to use and condition.

@if(\Route::current()->getName() != 'this_route' && \Route::current()->getName() != 'other_route')
    <div>Display when is true</div>
@endif

Upvotes: 1

Related Questions