PHP code example of az-iar / menu

1. Go to this page and download the library: Download az-iar/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/ */

    

az-iar / menu example snippets


namespace App\Menus;

class Dashboard {
    use AsMenuItem;
    
    public function href(): string
    {
        // TODO: Implement href() method.
    }

    public function title(): string
    {
        // TODO: Implement title() method.
    }
    
    // Override default method from `AsMenuItem` trait
    public function authorize(): bool
    {
        return auth()->check() && auth()->user()->can('view-dashboard');
    }
    ...
}

use Inneuron\NavMenu\Facades\Menu;
use Inneuron\Menu\Concerns\AsMenuItem;

// Add menu item


// Default menu
$menu = Menu::create()
    ->addItem(new Dashboard)
    ->addItem(new Users)
    ->addItem(new Settings);

// Another menu
$menu = Menu::create('profile')
    ->addItem(new MyProfile)
    ->addItem(new Notifications)
    ->addItem(new Settings);

use Inneuron\NavMenu\Facades\Menu;

// Output as array
Menu::get();
Menu::get('profile');

// Render in HTML
Menu::render();
Menu::render('profile');