How to catch if editor url is opened?

In laravel 8 app I select active menu item with

 <a class="nav-main-link {{ request()->is('admin/compilations') ? ' active_nav_menu' : '' }}"

and it works ok for link like :

http://127.0.0.1:8000/admin/compilations

But it does not work for link like :

http://127.0.0.1:8000/admin/compilations/2/edit

How can be fixed ?

Thanks in advance!


I think the cleanest solution for this is to gives your route names instead of hard-checking URL patterns (https://laravel.com/docs/8.x/routing#named-routes) and utilize one of the following methods:

$route = Route::current(); // Illuminate\Routing\Route
$name = Route::currentRouteName(); // string
$action = Route::currentRouteAction(); // string

If you have the $route instance you can also do something like $route->currentRouteNamed(...)

See full API here: https://laravel.com/api/8.x/Illuminate/Routing/Router.html#method_getCurrentRoute