PHP code example of cyberpunkcodes / laravel-menu-helper
1. Go to this page and download the library: Download cyberpunkcodes/laravel-menu-helper 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/ */
cyberpunkcodes / laravel-menu-helper example snippets
[
'my-menu' => [
'expanded' => true, // `$isExpanded()` - Optional - Default: false
'target' => 'collapseOne', // `$getTarget()` - Optional
'id' => 'headingOne', // `$getId()` - Optional - A random `mh_` prefixed id if empty
'title' => 'Accordion 1', // `$getTitle()`
'text' => "<strong>This is the first item's...", // `$getText()`
],
]
[
'my-menu' => [
// start: single item
[
'title' => 'Home', // `$getTitle()`
'icon' => '<i class="fa-solid fa-fw fa-house-chimney"></i>', // `$hasIcon()`, `$getIcon()`
'route' => 'dashboard', // named route - `route` key only supports a single route as a string
//'routes' => ['dashboard'], // we could also use an array list of all routes that match
'link' => ['dashboard'], // `$getLink()`named route for the link, null = no link
],
// end: single item
// start: dropdown item
[
'title' => 'Posts',
'icon' => '<i class="fa-solid fa-fw fa-book"></i>',
'routes' => ['posts.*'], // route matching: array list of all routes that match
'items' => [
// first sub-item
[
'title' => 'All Posts',
'route' => ['posts.index'],
'link' => ['posts.index'],
],
// second sub-item
[
'title' => 'Create Post',
'route' => ['posts.create'],
'link' => ['posts.create', ['foo' => 'bar']],
],
],
],
// end: dropdown item
]
]