Skip to content

Instantly share code, notes, and snippets.

@talha08
Created May 22, 2016 22:28
Show Gist options
  • Save talha08/aaca3ac96efbdfad4aae3010e7d8540e to your computer and use it in GitHub Desktop.
Save talha08/aaca3ac96efbdfad4aae3010e7d8540e to your computer and use it in GitHub Desktop.
Try this in a helpers file, or macro.
....................................................
/**
* Set active page
*
* @param string $uri
* @return string
*/
function set_active($uri)
{
return Request::is($uri) ? 'active' : '';
}
.....................................................
And then you can just do:
..................................................
<ul class="nav">
<li class="{{ set_active('home') }}"><a href="/home">Home</a></li>
<li class="{{ set_active('about') }}"><a href="/about">About</a></li>
</ul>
......................................................
https://laracasts.com/discuss/channels/general-discussion/navbar-and-active-elements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment