2 years ago

Laravel - Active status when on current page

Posted 2 years ago by Rainieren

Hello, I'm trying to add a custom active class to my navbar items if a user is on a specific page. I've tried many things I found on the internet, such as

<li class="nav-item mb-10 {{ Request::path() == '/adminpanel' ? 'class="custom-active"' : '' }}">
     <a class="nav-link text-center " href="{{ route('adminpanel') }}">
       <i class="fa fa-dashboard fa-font-size"></i><br>Dashboard

But for some reason, it just does not work. How can I accomplish this? It also says that request is an undefined class.

Please sign in or create an account to participate in this conversation.