I am creating and hiding a certain navigation in Laravel. The navigation uses nav tag
This is my current code:
@if (Request::url() === 'login')
<nav></nav>
@endif
Problem : I only want the tag to appear if it's not in LOGIN page.
Please help me fix the code above. Any help is appreciated.
This should work with your code.
! means IS NOT.
@if (!Request::url() === 'login')
<nav></nav>
@endif
So this code will run when the url isn't 'login'.
You could also use named routes
. ( https://laravel.com/docs/5.2/routing#named-routes )
Route::get('login', ['as' => 'login', 'uses' => 'ControllerName@methodName']);
Than you can check if the page is login
. You can do it like this:
@if(Route::is('login'))
This is the route 'login'
@endif
Hope this works!
make your login route as follows:
Route::get('login', ['as' => 'login', 'uses' => 'ControllerName@methodName']);
Now on view page just do as follows:
@if(Route::is('login'))
<nav></nav>
@endif
This will show the 'nav' tag when route is not login Hope this helps you.
This should do the trick:
the '!' means NOT, so the nav shows when the url is not login.
@if (!Request::is('login'))
<nav>I Am a menu item</nav>
@endif
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.