So i want to make my navbar post menu still active when i move from show posts route to the single post route.
this is the route: http://127.0.0.1:8000/posts/quia-laboriosam-nam-nostrum-porro
this is the navbar code
<li >
<a href="{{ url('/posts')}}">Blog</a>
</li>
this is the helper
function set_active($route)
{
if(is_array($route)){
return in_array(Request::path(), $route) ? 'active-menu' : '';
}
return Request::path() == $route ? 'active-menu' : '';
}
how can i make the navbar menu stay active?
CodePudding user response:
You can use the below method to handle navbar active or inactive in laravel,
<li @if(Request::is('posts') || Request::is('singleposts')) @endif>
<a href="{{ url('/posts')}}">Blog</a>
</li>