This package is abandoned and no longer maintained. No replacement package was suggested.

Laravel helper for detecting active navigation menu items and applying bootstrap classes.

2.0 2017-08-08 19:21 UTC

This package is not auto-updated.

Last update: 2020-01-22 19:23:17 UTC


Software License Packagist Version Total Downloads

Laravel helper that detects active navigation menu items and applies bootstrap classes. This is an implementation of In this implementation, you can use it with resouce name too.


First, pull in the package through Composer.

"require": {
    "lucadello91/laravel-active": "^2.0"

And then, if using Laravel 5 or 4, include the service provider within app/config/app.php.

'providers' => [

And, for convenience, add a facade alias to this same file at the bottom:

'aliases' => [
    'Active'    => Lucadello91\Active\Facades\LaravelActive::class


You would most likely use this package in your navbar partial like so:

    <a href="{{ route('home') }}" class="{{ Active::isActiveRoute('home') }}">
        <i class="halflings white home"></i> Home

    <a href="#" class="{{ Active::areActiveRoutes(['murter', 'kornati']) }}">
        <i class="halflings white screenshot"></i> Location
            <a href="{{ route('murter') }}">Murter</a>
            <a href="{{ route('kornati') }}">Kornati</a>

    <a href="{{ route('trips.index') }}" class="{{ Active::isActiveMatch('trips') }}">
        <i class="halflings white road"></i> Trips


As the second parameter to any method, you can pass the value you want to get returned if there was a match. By default this is active which is Bootstrap default.

As the third parameter to any method, you can pass the value you want to get returned if there wasn't a match. By default this is empty string.

isActiveRoute($routeName, $active = "active", $notActive = "")

Compares given route name with current route name.

{{ Active::isActiveRoute('home') }}

isActiveRouteResourceName($resourceName, $active = "active", $notActive = "")

Compares given resource name with current Route::Resource name.

{{ Active::isActiveRouteResourceName('home') }}

isActiveURL($url, $active = "active", $notActive = "")

Compares given URL with current URL.

{{ Active::isActiveURL('/about') }}

isActiveMatch($string, $active = "active", $notActive = "")

Detects if the given string is found in the current URL.

{{ Active::isActiveMatch('bout') }}

areActiveRoutes(array $routeNames, $active = "active", $notActive = "")

Compares given array of route names with current route name.

{{ Active::areActiveRoutes(['product.index', '']) }}

areActiveRoutesResourcesNames(array $resourcesNames, $active = "active", $notActive = "")

Compares given array of resource names with current Route::Resource name.

{{ Active::areActiveRoutesResourcesNames(['post', 'comments']) }}

areActiveURLs(array $urls, $active = "active", $notActive = "")

Compares given array of URLs with current URL.

{{ Active::areActiveURLs(['/product', '/product/create']) }}