Skip to content

Instantly share code, notes, and snippets.

@kel

kel/helpers.php

Last active May 2, 2016
Embed
What would you like to do?
<?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
You can’t perform that action at this time.