digithis/activehelper

Active helper is a simple active state system for your links in laravel 4
2,957 16
Install
composer require digithis/activehelper
PHP:>=5.3.0
License:MIT
Last Updated:Nov 21, 2013
Links: GitHub  ·  Packagist
Maintainer: digithis

##Active Helper active helper is a simple active state system for your links in laravel 4 ###How to install Add the following line in your composer.json

"digithis/activehelper": "dev-master"

Then run composer update

In app/config.app.php, add the following line to the providers array

'Digithis\Activehelper\ActivehelperServiceProvider',

In the aliases array, add the following line

'Active'  => 'Digithis\Activehelper\ActiveFacade',

###How to use Create a link and its current state :

echo Active::link('users', URL::to('users'), 'Show all users');

This means that if the current request is users, class for link is .active

Add several more routes as a first parameter :

echo Active::link(array('users', 'user/add', 'user/edit'), URL::to('users'), 'Show all users');

Use * as a pattern or exclude routes with not: :

echo Active::link(array('user*','not:user/edit'), URL::to('users'), 'Show all users');

This means that if the request begins with user but is not user/edit, class for link is .active

Set your own attributes if you wish:

echo Active::link(array('group*','not:groups*'), URL::to('group'), 'Show group', array('id' => 'mycustomid'));

You can also only get the current state (boolean)

$state = Active::is('page*','not:pages*');

And return the active class if the routes are matched

Active::classes('page*', 'not:pages*');

// Returns 'active'