Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A lightweight Laravel package to simplify building dynamic and structured menus in your applications.

License

NotificationsYou must be signed in to change notification settings

sukristyan/laravel-menu-wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Menu Wrapper is a lightweight package that helps you manage dynamic menus in your Laravel app with less effort.

Simply put, this package automatically generates an array of menus based on what you define.

Tested on Laravel10.x,11.x, and12.x — works successfully without any issues.

Installation

Using Composer (recommended):

cd your-laravel-projectcomposer require sukristyan/laravel-menu-wrapper

After the installation is complete, the provider and configuration files will be published automatically.

Configuration

Currently, there are only 2 configuration items.

Group As (group_as)

Values:item orkey.

This setting determines how your menus will be grouped.

key means that your group label will be used as the array key. Your defined menu will look like this:

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

item means that your group label will be included in the array asgroup_name, and your defined menus will be inserted underchilds. Your menu will look like this:

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

Populated Items (populated_items)

Here, you can define what you want to collect from the 'Illuminate\Routing\Route', or add custom identifiers to help integrate the menu into your application.

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

Usage

NOTE: All collected data will follow what you define inconfig/laravel-menu-wrapper.php.

Go to your 'routes/web.php', and add themenu('Menu Label', 'Group Label') function to your route:

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

After that, you can runphp artisan menu:list to show all your menus. You can also get all menus using this code:

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

You can parse the resulting menu array and use it anywhere in your project.

You can directly use it in aforeach loop, or create a custom page to manage the menu — allowing administrators to add or remove menu items for users.

$menus =app('sukristyan.menu')->all();foreach ($menusas$menu) {...}

License

Thesukristyan/laravel-menu-wrapper package is open-sourced software licensed under theMIT license.

About

A lightweight Laravel package to simplify building dynamic and structured menus in your applications.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp