active url laravel code example
Example 1: laravel sidebar menu active
{{ request()->routeIs('news.*') ? 'active' : '' }}
Example 2: laravel assign active based on route name
<li class="{{ Request::is('products*') ? 'active' : '' }}">
<a href="{{ route('products.index') }}"><span>Products</span></a>
</li>
Example 3: 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' : '';
}
Example 4: set nav link active on the basis of route laravel 8
<li class="{{ (request()->is('admin/cities*')) ? 'active' : '' }}">