How to Check Current Route in Laravel Blade
In this lesson we will see how to check the current route in Laravel blade, let's assume that we are working on a Laravel blog and we have a menu and we want to add an active class to the current menu item once clicked, so how we can do that?
Check Current Route in Laravel Blade
So to do that we check the current Laravel route using the method routeIs() that takes the route name as param if it is the current route we add the active class.
<li class="nav-item"><a class="nav-link @if(request()->routeIs('home')) active @endif" href="{{route('home')}}"><i class="fas fa-home"></i> Home</a></li>