Skip to content

Instantly share code, notes, and snippets.

@dogrocker
Last active September 12, 2015 21:49
Show Gist options
  • Save dogrocker/cd2a3419dae3985cbf0e to your computer and use it in GitHub Desktop.
Save dogrocker/cd2a3419dae3985cbf0e to your computer and use it in GitHub Desktop.
Laravel 5&5.1 set active class for nav

helper.php

function set_active($path, $active = 'active') {
    return call_user_func_array('Request::is', (array)$path) ? $active : '';
}

master.blade.php

<li class="{{ set_active(['backend/users*', 'backend/profile*']) }}">
    {!! link_to_route('backend.users.index', 'Manage Users', [],['class' => 'waves-effect waves-blue']) !!}
</li>

Ref: http://stackoverflow.com/a/29838296/2126472

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment