Created
May 22, 2016 22:28
-
-
Save talha08/aaca3ac96efbdfad4aae3010e7d8540e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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