title: Laravel 7 : how to use set Active class By Segments
body: <p>I'm using <a href="https://codeburst.io/just-in-case-laravel-handling-active-menu-item-932afe59cf9b" rel="nofollow noreferrer">this code</a> for set active class in nav menu But it does not work</p>
  <pre><code>function setActiveBySegments(string $path, string $class_name = &quot;is-active&quot;)
   {
     $request_path = implode('/', Request::segments());
  
     return $request_path === $path ? $class_name : &quot;&quot;;
   }
  </code></pre>
  <p>and in my nav.blade.php for edit Route</p>
  <blockquote>
  <p><a href="http://127.0.0.1:8000/admin/users/101/edit" rel="nofollow noreferrer">http://127.0.0.1:8000/admin/users/101/edit</a></p>
  </blockquote>
  <pre><code>&lt;li class=&quot;{{ setActiveBySegments('admin/users/*/edit','active') }}&quot;&gt;
  </code></pre>