Laravel Active
, (*1)
Laravel Active is a package for Laravel that makes it easy to recognize if the current path or route is active., (*2)
Requirements
Installation
Add Laravel Active to your composer file via the composer require command, (*3)
$ composer require imbue/laravel-active
Laravel 5.5 uses Package Auto-Discovery, so does not require you to manually add the ServiceProvider., (*4)
Publish the config file to your local config folder, (*5)
$ php artisan vendor:publish --tag=laravel-active
Usage
// by path
{{ active('articles') }}
{{ active('articles/*') }}
{{ active(['articles', 'articles/*']) }}
// by route name
{{ active('articles.*') }}
{{ active(['articles', 'articles.*']) }}
Example
<ul class="navbar-nav">
<li class="nav-item {{ active(['blog', 'blogs/*']) }}">
<a class="nav-link" href="#">Blog</a>
</li>
</ul>
Credits
This package is based on Active by dwightwatson and stripped down/changed to personal preference., (*6)