Looking to hire Laravel developers? Try LaraJobs

laravel-active maintained by tijdmachine

Description
Helper to check if the current route is active.
Author
Last update
2019/01/02 10:10 (dev-master)
License
Links
Downloads
43
Tags

Comments
comments powered by Disqus

Laravel Active

Latest Stable Version Total Downloads License

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.