hoaaah / laravel-bootstrap-menu
A packages for create bootstrap menu dynamically.
Installs: 80
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/hoaaah/laravel-bootstrap-menu
Requires
- php: >=5.5.9
 
This package is auto-updated.
Last update: 2025-10-25 18:54:32 UTC
README
Laravel Bootstrap Menu are helper to create dynamic menu within laravel. This helper temporary tested with SB Admin 2. So please be patient for further development.
Installation
The preferred way to install this extension is through composer.
Either run
composer require hoaaah/laravel-bootstrap-menu:dev-master
or add
"hoaaah/laravel-bootstrap-menu": "dev-master"
to the require section of your composer.json file.
Usage
You can use this helper in your view. It also support blade template.
Breadcrumb Skeleton
This helper consist of this following code.
use hoaaah\LaravelMenu\Menu as Menu;
// ..........
$menu = new Menu; // class
// render menu
$menu->render(
        'options' => [...] // optional
        'items' => [...]  // required
    );
Options
This is optional parameter. You can pass this following params in options.
- 
divClassparam are div class for your Bootstrap menu. Default value of divClass is 'sidebar-nav navbar-collapse'. You can change your div class withdivClassparam. - 
ulClassparam are ul class for your Bootstrap menu. Default value of ulClass is 'nav'. You can change your ul class withulClassparam. - 
ulIdparam are ul id for your Bootstrap menu. Default value of ulId is 'side-menu'. You can change your ul id withulIdparam. 
The following code as an example.
$menu->render(
        'options' => [
            'ulId' => 'side-menu'
        ],
        'items' => [...]  // required
    );
Items
items params are required to render menu. items is an array. This helper support three menu level. You can pass this following params in items.
labelis a string. This param use for label of your menu. This param is required foritemsurlis a string. This param use for link of your menu. You don't need to use 'url()' helper. This param is required unless this items are header of next level menu (dropdown)iconis a string. This param use for icon of your menu. Default value oficonisfa fa-circle-o. This param is optional, you can change the icon of your menu withiconparam.visibleis a bool. This param use for visibility of your menu. Default value ofvisibleis 'true'. This param is optional, you can change visibility of your menu withvisibleparamitemsis an array. This param use for add another level of your menu. You can use all of items params in this param. Ifitemsparam exist,urlparam will be ignored.
The following code are complete example of breadcrumb item
use hoaaah\LaravelMenu\Menu as Menu;
$menu = new Menu; // class
$menu->render(
        'options' => [
            'ulId' => 'side-menu'
        ],
        'items' => [
            ['label' => 'Dashboard', 'icon' => 'fa fa-home', 'url' => '/'],
            [
                'label' => 'First Level 1',
                'visible' => true,
                'items' => [
                    ['label' => 'Second Level -1', 'url' => '/renja'],
                    ['label' => 'Second Level -2', 'url' => '/renja'],
                ]
            ],            
            [
                'label' => 'First Level 2',
                'items' => [
                    [
                        'label' => 'Second Level 1',
                        'visible' => true,
                        'items' => [
                            ['label' => 'Third Level 1', 'url' => '/ranwalrkpd'],
                            ['label' => 'Third Level 2', 'url' => '/ranwalrkpd'],
                        ]
                    ],
                ]
            ],
        ]
    );