PHP code example of vynatu / menu
1. Go to this page and download the library: Download vynatu/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/ */
vynatu / menu example snippets
'providers' => [
...
Vynatu\Menu\MenuServiceProvider::class,
]
'providers' => [
...
App\Providers\MenuServiceProvider::class,
]
namespace App\Menus;
use Vynatu\Menu\MenuInstance;
class AdminMainMenu extends MenuInstance
{
public function generate()
{
//
}
}
function generate()
{
$this->menu->add('Dashboard')->url('/home'); // Method 1
$this->menu->add('My Account', '/'); // Method 2
$this->menu->add('List Users', 'route:users.list'); // Method 3
$this->menu->add('Seperator')->section(); // Method 4
$this->menu->add('Edit Myself', 'route:users.edit|id:5'); // Method 5
$this->menu->add('Logout')->route('auth.logout'); // Method 6
$this->menu->add('Some Other Link', ['url' => '/link']); // Method 7
}
function boot(\Vynatu\Menu\MenuManager $menu)
{
$menu->register('main_menu', \App\Menus\MainMenu::class);
}
function boot(\Vynatu\Menu\MenuManager $menu)
{
$menu->extend('main_menu', \App\Menus\MainMenuExtender::class);
}
public function generate()
{
$this->menu->management->add(...);
}
public function generate()
{
$this->menu->add(_t('menus.management'))->route('admin.management')->slug('management');
}
public function generate()
{
$this->menu->management->icon('fa fa-home');
}
public function generate()
{
$this->menu->management->icon('fa fa-home');
}
public function generate()
{
$this->menu->management->icon = 'fa fa-home';
}
blade
@foreach($menu->items() as $item)
@if($item->hasSubItems())
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
aria-expanded="false">{{ $item->title }}<span class="caret"></span></a>
<ul class="dropdown-menu">
@