Advertisement
Khasky

Laravel Framework / route helper

Sep 19th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. |--------------------------------------------------------------------------
  5. | Detect Active Route
  6. |--------------------------------------------------------------------------
  7. |
  8. | Compare given route with current route and return output if they match.
  9. | Very useful for navigation, marking if the link is active.
  10. |
  11. */
  12. function isActiveRoute($route, $cssClass = "active")
  13. {
  14.     //if (strpos(Route::currentRouteName(), $route) !== false)
  15.     if (Route::currentRouteName() == $route)
  16.         return $cssClass;
  17. }
  18.  
  19. /*
  20. |--------------------------------------------------------------------------
  21. | Detect Active Routes
  22. |--------------------------------------------------------------------------
  23. |
  24. | Compare given routes with current route and return output if they match.
  25. | Very useful for navigation, marking if the link is active.
  26. |
  27. */
  28. function areActiveRoutes(Array $routes, $cssClass = "active")
  29. {
  30.     foreach ($routes as $route)
  31.     {
  32.         if (Route::currentRouteName() == $route)
  33.             return $cssClass;
  34.     }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement