Here are two ways to check the route name in Laravel.
// #1<a href="{{ route('home') }}" @class="['navbar-link', 'active' => Route::current()->getName() === 'home']"> Home</a>// #2<a href="{{ route('home') }}" @class="['navbar-link', 'active' => request()->routeIs('home)]"> Home</a>
Tip given by @AndrewSavetchuk
Enjoyed This Tip?
Get access to all premium tutorials, video and text courses, and exclusive Laravel resources. Join our community of 10,000+ developers.
Recent Courses
How to Structure Laravel 13 Projects
16 lessons
1 h 32 min read
[NEW] Laravel AI SDK: 6 Practical Examples
9 lessons
1 h 02 min
Livewire v3 to v4: Changes You Need to Know
7 lessons
31 min