Laravel assign active based on route name
Laravel assign active based on route name
<li class="{{ Request::is('products*') ? 'active' : '' }}">
<a href="{{ route('products.index') }}"><span>Products</span></a>
</li>
Laravel sidebar menu active
{{ request()->routeIs('news.*') ? 'active' : '' }}
Laravel assign active based on route name
<li class = "{{ set_active('admin/users') }}">
<a href="{{ url('/admin/users/') }}">Users</a>
</li>
Laravel assign active based on route name
function set_active( $route ) {
if( is_array( $route ) ){
return in_array(Request::path(), $route) ? 'active' : '';
}
return Request::path() == $route ? 'active' : '';
}
0 comments:
Post a Comment
Thanks