2017 © Pedro Peláez
 

library laravel-active

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

image

lucadello91/laravel-active

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

  • Wednesday, July 11, 2018
  • by lucadello91
  • Repository
  • 0 Watchers
  • 2 Stars
  • 415 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 6 Versions
  • 9 % Grown

The README.md

Laravel-Active

Software License Packagist Version Total Downloads, (*1)

Laravel helper that detects active navigation menu items and applies bootstrap classes. This is an implementation of https://github.com/laravelista/Ekko. In this implementation, you can use it with resouce name too., (*2)

Installation

First, pull in the package through Composer., (*3)

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

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

'providers' => [
    Lucadello91\Active\LaravelActiveServiceProvider::class
];

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

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

Usage

You would most likely use this package in your navbar partial like so:, (*6)

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

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

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

API

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., (*7)

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., (*8)

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

Compares given route name with current route name., (*9)

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

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

Compares given resource name with current Route::Resource name., (*10)

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

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

Compares given URL with current URL., (*11)

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

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

Detects if the given string is found in the current URL., (*12)

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

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

Compares given array of route names with current route name., (*13)

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

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

Compares given array of resource names with current Route::Resource name., (*14)

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

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

Compares given array of URLs with current URL., (*15)

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

The Versions

11/07 2018

dev-master

9999999-dev https://github.com/lucadello91/laravel-active

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

  Sources   Download

MIT

The Requires

 

laravel bootstrap helper navigation

08/08 2017

2.0

2.0.0.0 https://github.com/lucadello91/laravel-active

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

  Sources   Download

MIT

The Requires

 

laravel bootstrap helper navigation

08/08 2017

V2.0beta

2.0.0.0-beta https://github.com/lucadello91/laravel-active

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

  Sources   Download

MIT

The Requires

 

laravel bootstrap helper navigation

22/03 2016

1.1

1.1.0.0 https://github.com/lucadello91/laravel-active

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

  Sources   Download

MIT

The Requires

 

laravel bootstrap helper navigation

30/01 2016

1.0.1

1.0.1.0 https://github.com/lucadello91/laravel-active

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

  Sources   Download

MIT

The Requires

 

laravel bootstrap helper navigation

30/01 2016

1.0

1.0.0.0 https://github.com/lucadello91/laravel-active

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

  Sources   Download

MIT

The Requires

 

laravel bootstrap helper navigation