PHPackages                             vfixtechnology/laravel-menu - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. vfixtechnology/laravel-menu

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

vfixtechnology/laravel-menu
===========================

drag and drop menu generator like wordpress for laravel 9

31021JavaScript

Since Oct 7Pushed 2y ago1 watchersCompare

[ Source](https://github.com/vfixtechnology/laravel-menu)[ Packagist](https://packagist.org/packages/vfixtechnology/laravel-menu)[ RSS](/packages/vfixtechnology-laravel-menu/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

laravel-menu
============

[](#laravel-menu)

Laravel dyanmic menu like wordPress

Laravel Drag and drop dynamic menu like wordPress
=================================================

[](#laravel-drag-and-drop-dynamic-menu-like-wordpress)

[![Larvel Dynamic Menu](screenshot.png)](screenshot.png)[![Laravel Wordpress Menu](img/one.png)](img/one.png)[![Laravel Drag and Drop Menu](img/two.png)](img/two.png)

Installation
============

[](#installation)

1. Run

```
composer require vfixtechnology/laravel-menu:dev-master
```

**Step 2 &amp; 3 are optional if you are using laravel 9 or 10**

2. Add the following class, to "providers" array in the file config/app.php (optional on laravel 9)

```
Vfixtechnology\Menu\MenuServiceProvider::class,
```

3. add facade in the file config/app.php (optional on laravel 9)

```
'Menu' => Vfixtechnology\Menu\Facades\Menu::class,
```

4. Run publish

```
php artisan vendor:publish --provider="Vfixtechnology\Menu\MenuServiceProvider"
```

5. Configure (optional) in ***config/menu.php*** :

- ***CUSTOM MIDDLEWARE:*** You can add you own middleware
- ***TABLE PREFIX:*** By default this package will create 2 new tables named "menus" and "menu\_items" but you can still add your own table prefix avoiding conflict with existing table
- ***TABLE NAMES*** If you want use specific name of tables you have to modify that and the migrations
- ***Custom routes*** If you want to edit the route path you can edit the field
- ***Role Access*** If you want to enable roles (permissions) on menu items

6. Run migrate

```
php artisan migrate
```

DONE

### Menu Builder Usage Example - displays the builder

[](#menu-builder-usage-example---displays-the-builder)

On your view blade file

```
@extends('app')

@section('content')
    {!! Menu::render() !!}
@endsection

//YOU MUST HAVE JQUERY LOADED BEFORE menu scripts
@push('scripts')
    {!! Menu::scripts() !!}
@endpush
```

### Using The Model

[](#using-the-model)

Call the model class

```
use Vfixtechnology\Menu\Models\Menus;
use Vfixtechnology\Menu\Models\MenuItems;
```

### Menu Usage Example (a)

[](#menu-usage-example-a)

A basic two-level menu can be displayed in your blade template

##### Using Model Class

[](#using-model-class)

```
/* get menu by id*/
$menu = Menus::find(1);
/* or by name */
$menu = Menus::where('name','Test Menu')->first();

/* or get menu by name and the items with EAGER LOADING (RECOMENDED for better performance and less query call)*/
$menu = Menus::where('name','Test Menu')->with('items')->first();
/*or by id */
$menu = Menus::where('id', 1)->with('items')->first();

//you can access by model result
$public_menu = $menu->items;

//or you can convert it to array
$public_menu = $menu->items->toArray();
```

##### or Using helper

[](#or-using-helper)

```
// Using Helper
$public_menu = Menu::getByName('Public'); //return array
```

### Menu Usage Example (b)

[](#menu-usage-example-b)

Now inside your blade template file place the menu using this simple example

```

        @if($public_menu)

            @foreach($public_menu as $menu)

                {{ $menu['label'] }}
                @if( $menu['child'] )

                    @foreach( $menu['child'] as $child )
                        {{ $child['label'] }}
                    @endforeach

                @endif

            @endforeach
        @endif

```

### HELPERS

[](#helpers)

### Get Menu Items By Menu ID

[](#get-menu-items-by-menu-id)

```
use Vfixtechnology\Menu\Facades\Menu;
...
/*
Parameter: Menu ID
Return: Array
*/
$menuList = Menu::get(1);
```

### Get Menu Items By Menu Name

[](#get-menu-items-by-menu-name)

In this example, you must have a menu named *Admin*

```
use Vfixtechnology\Menu\Facades\Menu;
...
/*
Parameter: Menu ID
Return: Array
*/
$menuList = Menu::getByName('Admin');
```

### Want to add the extra features like category and posts follow steps:

[](#want-to-add-the-extra-features-like-category-and-posts-follow-steps)

Step 1: Open the MenuController path vendor/vfixtechnology/laravel-menu/src/Controllers/MenuController

```
    public function addCategory(Request $request)
    {
        $categories = $request->input('categories');

        foreach ($categories as $categoryData) {
            if ($categoryData['url']) {
                $menuItem = new MenuItems();
                if (config('menu.use_roles')) {
                    $menuItem->role_id = $request->input("rolemenu") ? $request->input("rolemenu") : 0;
                }
                $menuItem->menu = $request->input("idmenu");
                $menuItem->sort = MenuItems::getNextSortRoot($request->input("idmenu"));
                $menuItem->label = $categoryData['name'];
                $menuItem->link = $categoryData['url'];
                $menuItem->save();
            }
        }

        return response()->json(['message' => 'Categories added successfully']);
    }
```

This logic is to add categories in the menu

Step 2: Pass data to blade and create form in resources/view/vendor/wmenu/menu-html.blade.php

```
    @php
        $categories = [
            ['id' => 1, 'name' => 'Category 1', 'slug' => 'category-1'],
            ['id' => 2, 'name' => 'Category 2', 'slug' => 'category-2'],
            ['id' => 3, 'name' => 'Category 3', 'slug' => 'category-3'],
            // Add more categories as needed
        ];
    @endphp

        @csrf

                        Category Link Press return
                            or enter to expand

                                @foreach ($categories as $category)

                                        {{ $category['name'] }}

                                    {{ $category['name'] }}

                                @endforeach

                                @if (!empty($roles))

                                            Role&nbsp;

                                                Select Role

                                                @foreach ($roles as $role)

                                                        {{ ucfirst($role->$role_title_field) }}

                                                @endforeach

                                @endif

                                    Add
                                        menu items

```

Here I have used the static category list you can get it dynamically by using the controller too

Step 3: Now Create the js code to send the AJAX Request in resources/views/vendor/wmenu/menu-html.blade.php (in footer)

```

        function addCategories() {
        $('#spincategory').show();

        var categoriesData = [];

        $('[id^=category-slug]').each(function() {
            var categoryId = $(this).attr('id').replace('category-slug', '');

            if ($('#category-checkbox' + categoryId).is(':checked')) {
                var categoryData = {
                    url: $(this).val(),
                    name: $('#category-label' + categoryId).text()
                };
                categoriesData.push(categoryData);
            }
        });

        $.ajax({
            data: {
                categories: categoriesData,
                rolemenu: $('#category-menu-item-role').val(),
                idmenu: $('#idmenu').val()
            },
            url: '{{ route('addCategory') }}',
            type: 'POST',
            success: function(response) {
                console.log('Categories added successfully');
                window.location.reload();
            },
            error: function(xhr, textStatus, errorThrown) {
                console.log('AJAX Error:', errorThrown);
               // console.log('Response:', xhr.responseText);
            },
            complete: function() {
                $('#spincategory').hide();
            }
        });

        // console.log('AJAX Request Payload:', {
        //     categories: categoriesData
        // });
    }

```

Step 4: Create the route to send the request Add this route code in the route.php file vendor/vfixtechnology/laravel-menu/routes.php

```
Route::post($path . '/addCategoryToMenu',array('as' => 'addCategory', 'uses' => '\vfixtechnology\Menu\Controllers\MenuController@addCategory'));
```

Step 5: Now add below code to activate the live search using jquery in resources/views/vendor/wmenu/menu-html.blade.php

Add jquery via CDN or local file

```

```

Then add the below jQuery code to add the live search

```

        $(document).ready(function() {
            $('#category-search').on('input', function() {
                var searchText = $(this).val().toLowerCase();

                $('.category-item').each(function() {
                    var categoryText = $(this).text().toLowerCase();
                    if (categoryText.includes(searchText)) {
                        $(this).show();
                    } else {
                        $(this).hide();
                    }
                });
            });
        });

```

### Follow the similar step for to add posts, pages or anything.

[](#follow-the-similar-step-for-to-add-posts-pages-or-anything)

### Compatibility

[](#compatibility)

- Tested with laravel 8.x, 9.x, 10.x

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity21

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/1dcb069b38b990252aba1ecb79921c68ccab25305d67b15d1a6c2c1f76bf2e88?d=identicon)[vfixtechnology.com](/maintainers/vfixtechnology.com)

---

Top Contributors

[![vfixtechnology](https://avatars.githubusercontent.com/u/140944193?v=4)](https://github.com/vfixtechnology "vfixtechnology (7 commits)")

### Embed Badge

![Health badge](/badges/vfixtechnology-laravel-menu/health.svg)

```
[![Health](https://phpackages.com/badges/vfixtechnology-laravel-menu/health.svg)](https://phpackages.com/packages/vfixtechnology-laravel-menu)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
