Skip to content

Instantly share code, notes, and snippets.

@kel
Last active May 2, 2016 21:25
Show Gist options
  • Save kel/a264b3fd2f1d9caf084eb24784470f2a to your computer and use it in GitHub Desktop.
Save kel/a264b3fd2f1d9caf084eb24784470f2a to your computer and use it in GitHub Desktop.
<?php
/**
* Adds active to the class if current path
* equals passed path. Allows custom
* classes as well.
*
* @param $paths
* @param null $classes
* @return string
*/
function active_class_path($paths, $classes = null)
{
foreach ((array) $paths as $path) {
if (request()->is($path)) {
return 'class="' . ($classes ? $classes . ' ' : '') . 'active"';
}
}
return $classes ? 'class="' . $classes . '"' : '';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment