tijdmachine/laravel-active

This package is abandoned and no longer maintained. The author suggests using the imbue/laravel-active package instead.

Helper to check if the current route is active.

1.0.0 2018-01-14 22:22 UTC

This package is auto-updated.

Last update: 2022-02-01 13:11:51 UTC


README

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.