Laravel Voyager New menu added on sidebar

copy vendor file
vendor\tcg\voyager\resources\views
to
resources\views\vendor\voyager

check file
resources\views\vendor\voyager\dashboard\sidebar.blade.php

        <div id="adminmenu"> <!-- MODIFIED FOR CUSTOM MENUS -->
            @if (Auth::user()->hasRole('user'))
            <!-- APPEND CUSTOM MENU FOR ROLE: USER -->
            <!-- Needs more customization/details -->
            @php // Custom Menu for Role: User
            
            //new custom menu name admin2
            $items = menu('admin2', '_json');
            @endphp
            <ul class="nav navbar-nav">
                @foreach($items as $itemm)
                
                @php
                
                $currenturl = explode("/", $itemm['url']) ;
                echo "<li class=".(isset($currenturl[2]) && $currenturl[2] ==  request()->segment(2) ? 'active' : ((url()->current() ==  url($itemm['url']) ? 'active' : '')) ).">
                <a target='_self' href=".url($itemm['url']).">
                <span class='icon ".$itemm['icon_class']."'></span> 
                <span class='title'>".$itemm['title']."</span></a>
                </li>";
                @endphp
        
                @endforeach
            </ul>
            @endif
            <!-- END APPEND CUSTOM MENU FOR ROLE: USER -->
            <!-- ORIGINAL MENU ADMIN -->
            @if (Auth::user()->hasRole('admin'))
            <admin-menu :items="{{ menu('admin', '_json') }}"></admin-menu>
            <!-- END ORIGINAL MENU ADMIN -->
            @endif
        </div>

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *