PHP code example of logicalcrow / menu-sub

1. Go to this page and download the library: Download logicalcrow/menu-sub library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

logicalcrow / menu-sub example snippets


'providers' => [
    /*
     * Package Service Providers...
     */
    Logicalcrow\Menu\Providers\MenuServiceProvider::class,
],

use Logicalcrow\Menu\Models\Menu;

// add function at end of Models/User.php
public function menus()
{
    return $this->belongsToMany(Menu::class, 'menu_users')->orderByPivot('menu_id');
}

@foreach($menus as $menu)
    <li class="menu-item menu-item-submenu {{ Request::is('dashboard/'.$menu->url.'/*') ? 'menu-item-open menu-item-here' : '' }}" aria-haspopup="true" data-menu-toggle="hover">
        <a href="javascript:;" class="menu-link menu-toggle">
            <span class="svg-icon menu-icon">
                <i class="kt-menu__link-icon {{ $menu->ico }}"></i>
            </span>
            <span class="menu-text">{{ $menu->name }}</span>
            <i class="menu-arrow"></i>
        </a>
        @if(isset($menu->menuSubs))
            <div class="menu-submenu">
                <i class="menu-arrow"></i>
                <ul class="menu-subnav">
                    @foreach($menu->menuSubs as $menuSub)
                    <li class="menu-item {{ Request::is('dashboard/'.$menu->url.'/'.$menuSub->url, 'dashboard/'.$menu->url.'/'.$menuSub->url.'/*') ? 'menu-item-active' : '' }}" aria-haspopup="true">
                        <a href="/dashboard/{{ $menu->url }}/{{ $menuSub->url }}" class="menu-link">
                            <i class="menu-bullet menu-bullet-dot">
                                <span></span>
                            </i>
                            <span class="menu-text">{{ $menuSub->name }}</span>
                        </a>
                    </li>
                    @endforeach
                </ul>
            </div>
        @endif
    </li>
@endforeach