Current URL inside @if statements in Laravel
When you need to access the current url inside an if statement in laravel 4 you can do it like the example given below.
@if(Request::url() === 'your url here')
// code
@endif
Another method is:
<li{!!(Request::is('your_url')) ? ' class="active"' : '' !!}>
or
<li @if(Request::is('your_url'))class="active"@endif>
To get the url in the blade you can use current().
<a href="{{url()->current()}}">Current Url</a>
request() is another way to get the current url.
<li class="{{ Request::is('mycategory/', '*') ? 'active' : ''}}">
Comments
0 comments
Please Sign in or Create an account to Post Comments