Skip to content

An active HTML class helper that echo's strings based on the current route.

Notifications You must be signed in to change notification settings

BaraaDev/active

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Active

An active HTML class helper that echo's strings based on the current route.

Build Status Scrutinizer Code Quality Total Downloads Latest Stable Version License

🚨 Abandoned 🚨

This package has been abandoned in favor or Laravel's now default implementation request()->routeIs($pattern) method.

The above method now exists for any Laravel application that is version 5.4 or greater.

This repository will still remain up on both Packagist and GitHub.

Installation

Insert active inside your composer.json:

"stevebauman/active": "1.0.*"

Insert the service provider in config/app.php only if you need the configuration file.

\Stevebauman\Active\ActiveServiceProvider::class,

Run composer update, and you're all set!

Usage

This documentation will use the active() helper.

The default output class is active, which is the standard bootstrap class for displaying buttons and links in a different color if they match the current URL.

Output on active routes or route:

<!-- `active` will be displayed when you visit `products/index` -->
<a
    class="btn btn-success {{ active()->route('products.index') }}"
    href="{{ route('products.index') }}">
        Products
</a>
<!-- `active` will be displayed when you visit `products/index` or `products/create` -->
<a
    class="btn btn-success {{ active()->routes(['products.index', 'products.create']) }}"
    href="{{ route('products.index') }}">
        Products
</a>

To output active on any routes below a certain route, use the wildcard (*) inside your route.

For example:

<!-- `active` will be displayed when you visit any route below `products.` -->
<a
    class="btn btn-success {{ active()->route('products.*') }}"
    href="{{ route('products.index') }}">
        Products
</a>
<!-- `active` will be displayed when you visit any route below `products.`, or `suppliers.` -->
<a
    class="btn btn-success {{ active()->routes(['products.*', 'suppliers.*']) }}"
    href="{{ route('products.index') }}">
        Products
</a>

Setting a different output

To set a different output, use the output() method:

<a
    class="btn btn-success {{ active()->output('my-active-class')->route('products.*') }}"
    href="{{ route('products.index') }}">
        Products
</a>

About

An active HTML class helper that echo's strings based on the current route.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages