PHP code example of sukristyan / laravel-menu-wrapper

1. Go to this page and download the library: Download sukristyan/laravel-menu-wrapper 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/ */

    

sukristyan / laravel-menu-wrapper example snippets


[
    'Group Name' => [
        [
            'label' => 'Menu #1',
        ],
        [
            'label' => 'Menu #2',
        ]
    ],
    ...
]

[
    [
        'group_name' => 'Group Name',
        'childs' => [
            [
                'label' => 'Menu #1',
            ],
            [
                'label' => 'Menu #2',
            ],
        ],
    ],
    ...
]

'populate_items' => function (Route $route) {
    return [
        'route_name' => $route->getName(),
        'type' => 'children'
    ];
}

Route::get('index', [DashboardController::class, 'index'])
    ->name('index')
    ->menu('Dashboard');

app('sukristyan.menu')->all();

$menus = app('sukristyan.menu')->all();

foreach ($menus as $menu) {
    ...
}