1. Go to this page and download the library: Download smartystudio/laravelmenu 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/ */
use SmartyStudio\LaravelMenu\Models\Menu;
use SmartyStudio\LaravelMenu\Models\MenuItem;
// Get menu by ID
$menu = Menu::find(1);
// Get menu by Name
$menu = Menu::where('name','Test Menu')->first();
/**
* Get menu by Name and the Items with eager loading.
* This is RECOMENDED for better performance and less query calls.
*/
$menu = Menu::where('name','Test Menu')->with('items')->first();
// Get menu by ID
$menu = Menu::where('id', 1)->with('items')->first();
// Access by Model result
$public_menu = $menu->items;
// Convert it to Array
$public_menu = $menu->items->toArray();
// Using Helper
$public_menu = Menu::getByName('Public'); // return array
use SmartyStudio\LaravelMenu\Facades\Menu;
...
/**
* Parameter: Menu ID
* Return: Array
*/
$menuList = Menu::get(1);
use SmartyStudio\LaravelMenu\Facades\Menu;
...
/**
* Parameter: Menu ID
* Return: Array
*/
$menuList = Menu::getByName('Admin');