Laravel: How to Make Menu Item Active by URL
In this article I will help you to Make Menu Item Active by URL just you have to follow the procedure using helper function $request->is().
Approach 1 : Exact URL
<li class="{{ (request()->is('admin')) ? 'active' : '' }}">
We use helper function $request->is().
Approach 2 : Starting with the URL
More flexible – will also match any other URL, like /admin/create or /admin/1/edit.
We use asterisk (*) symbol.
<li class="{{ (request()->is('admin/*')) ? 'active' : '' }}">
Approach 3 : Matching URL Segment
<li class="{{ (request()->segment(2) == 'example') ? 'active' : '' }}">