1. Go to this page and download the library: Download harimayco/laravel-menu 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/ */
@extends('app')
@section('contents')
{!! Menu::render() !!}
@endsection
//YOU MUST HAVE JQUERY LOADED BEFORE menu scripts
@push('scripts')
{!! Menu::scripts() !!}
@endpush
use Harimayco\Menu\Models\Menus;
use Harimayco\Menu\Models\MenuItems;
/* get menu by id*/
$menu = Menus::find(1);
/* or by name */
$menu = Menus::where('name','Test Menu')->first();
/* or get menu by name and the items with EAGER LOADING (RECOMENDED for better performance and less query call)*/
$menu = Menus::where('name','Test Menu')->with('items')->first();
/*or by id */
$menu = Menus::where('id', 1)->with('items')->first();
//you can access by model result
$public_menu = $menu->items;
//or you can convert it to array
$public_menu = $menu->items->toArray();
// Using Helper
$public_menu = Menu::getByName('Public'); //return array