Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Amalmax's avatar

Not working bootstrap navbar with <ul class=“nav nav-sidebar”> in Laravel 5.6

in my laravel application I have sidebar menu like following,

<ul class="nav navbar-nav">
      <li class="{{ active_menu(Route::CurrentRouteName(), 'welcome', 0,7)}}">
      <a href="{{route('welcome')}}">Home</a></li>

      <li class="{{ active_menu(Route::CurrentRouteName(), 'page1', 0,5)}}">
      <a href="{{route('page1')}}">Page 1</a></li>
      <li><a href="#">Page 2</a></li>
      <li><a href="#">Page 3</a></li>
    </ul>

this is working with Helper.php file in app/Helper/Helper.php3

<?php

if(! function_exists('active_menu')) {
    function active_menu($currentRouteName, $requestName, $start, $finish){
        if (substr($currentRouteName,$start, $finish) == $requestName){
            return 'active';

        }else{
            return null;
        }
    }
    }

this is working fine, but now I need change above sidemenu bar class as following,

<ul class="nav nav-sidebar">

only this change but now it is not working. how can I fix this problem?

0 likes
8 replies
manelgavalda's avatar

Hey, I had a similar problem, and it was because I was using bootstrap 4 instead of bootstrap 3, and many things are changed.

Amalmax's avatar

@globals then what is the using sidebar class in bootstrap 4? you know that?

Amalmax's avatar

what about any ideas about this problem?

Snapey's avatar

You and @flex working on the same project or are the same person?

This is a css issue, not Laravel 5.6

Snapey's avatar

Then the advice is the same. Its a CSS issue that only you can sort out with the development tools in the browser.

It does not matter how you apply the active class.. that appears to not be the problem

Please or to participate in this conversation.