Skip to content

Instantly share code, notes, and snippets.

@lighta971
Created December 20, 2013 13:07
Show Gist options
  • Save lighta971/8054541 to your computer and use it in GitHub Desktop.
Save lighta971/8054541 to your computer and use it in GitHub Desktop.
Laravel Menu active state helper Add to composer.json: "autoload": { "files": ["app/helpers.php"] } Then run "composer dump" #http://paste.laravel.com/1acS
// helper
function set_active($path, $active = 'active') {
return call_user_func_array('Request::is', (array)$path) ? $active : '';
}
// usage in view
<li class="{{ set_active(['admin/institutes*','admin/courses*']) }}">
or
<li class="{{ set_active('admin/dashboard') }}">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment