imbue / laravel-active
Helper to check if the current route is active.
1.0.0
2018-01-14 22:22 UTC
Requires
- php: >=7.0
- laravel/framework: >=5.5
This package is auto-updated.
Last update: 2024-10-29 05:10:41 UTC
README
Laravel Active is a package for Laravel that makes it easy to recognize if the current path or route is active.
Requirements
- Laravel >=5.5
Installation
Add Laravel Active to your composer file via the composer require command
$ composer require imbue/laravel-active
Laravel 5.5 uses Package Auto-Discovery, so does not require you to manually add the ServiceProvider.
Publish the config file to your local config folder
$ 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.