Last active
August 29, 2015 14:02
-
-
Save J5Dev/0a5757a2a7d47d4a7ac1 to your computer and use it in GitHub Desktop.
Revisions
-
J5Dev revised this gist
Jun 25, 2014 . 1 changed file with 12 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -15,14 +15,22 @@ { // create the href value $href = route($route, $params); // set whether the supplied route is the current url $is_active = ($route == Route::currentRouteName()); } else { // check if an external domain is supplied if( ! preg_match('/([a-z0-9\-]+)\.([a-z]+|[a-z]{2}\.[a-z]+)$/im', $route)) { // create the href value $href = url($route); } else { $href = $route; } // check whether the supplied url is the current on or a child of $is_active = Request::is($route . '*'); } -
J5Dev created this gist
Jun 24, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ <?php HTML::macro('navLink', function ($route, $text, $listAttributes = [], $linkAttributes = [], $params = null, $secure = null) { # Set default attributes $listDefaults = ['class' => '']; $linkDefaults = ['class' => '']; // Merge default attributes with those supplied $listAttributes = $listDefaults + ($listAttributes == null ? [] : $listAttributes); $linkAttributes = $linkDefaults + ($linkAttributes == null ? [] : $linkAttributes); // check if supplied route is a named route or text url if (Route::getRoutes()->hasNamedRoute($route)) { // create the href value $href = route($route, $params); // set whether the supplied route is the current url $is_active = ($route == Route::currentRouteName()); } else { // create the href value $href = url($route); // check whether the supplied url is the current on or a child of $is_active = Request::is($route . '*'); } # Append active class if wanted if ($is_active) { $listAttributes['class'] .= ' active'; $linkAttributes['class'] .= ' active'; } return '<li ' . HTML::attributes($listAttributes) . '>' . link_to($href, $text, $linkAttributes, $secure) . '</li>'; });