public function check($parSegments, $parLastSegment = null)
{
$allSegments = \Route::getCurrentRequest()->segments();
$countSegments = count($allSegments) - 1;
if ($countSegments < 0) {
$countSegments = 0;
}
if (empty($allSegments)) {
$firstSegment = '';
$lastSegment = '';
} else {
$firstSegment = $allSegments[0];
$lastSegment = $allSegments[$countSegments];
}
if (is_string($parSegments)) {
return $firstSegment == $parSegments && (!$parLastSegment || $parLastSegment == $lastSegment) ? 'active' : '';
} elseif (is_array($parSegments)) {
$allSegmentsMatch = true;
for ($i = 0; $i < count($parSegments); $i++) {
if (!array_key_exists($i, $parSegments) || !array_key_exists($i, $allSegments) || $parSegments[$i] != $allSegments[$i]) {
$allSegmentsMatch = false;
break;
}
}
return $allSegmentsMatch && (!$parLastSegment || $parLastSegment == $lastSegment) ? 'active' : '';
} else {
return '';
}
}