PHPackages                             itstructure/laravel-multi-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. itstructure/laravel-multi-menu

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

itstructure/laravel-multi-menu
==============================

Widget for rendering multilevel menu for Laravel framework

2.0.9(1y ago)4242MITPHPPHP &gt;=7.1.0CI failing

Since Jun 27Pushed 2d agoCompare

[ Source](https://github.com/itstructure/laravel-multi-menu)[ Packagist](https://packagist.org/packages/itstructure/laravel-multi-menu)[ RSS](/packages/itstructure-laravel-multi-menu/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (1)Versions (14)Used By (0)

Laravel MultiMenu widget
========================

[](#laravel-multimenu-widget)

1 Introduction
--------------

[](#1-introduction)

[![Latest Stable Version](https://camo.githubusercontent.com/365538fd690e65d491a32417e58477fd735b9ad0e475c62e581e5990c0584483/68747470733a2f2f706f7365722e707567782e6f72672f69747374727563747572652f6c61726176656c2d6d756c74692d6d656e752f762f737461626c65)](https://packagist.org/packages/itstructure/laravel-multi-menu)[![Latest Unstable Version](https://camo.githubusercontent.com/28d8e612051deb589fbc8833b73c46d38f772b174f88b6f95b96f630b6d60bce/68747470733a2f2f706f7365722e707567782e6f72672f69747374727563747572652f6c61726176656c2d6d756c74692d6d656e752f762f756e737461626c65)](https://packagist.org/packages/itstructure/laravel-multi-menu)[![License](https://camo.githubusercontent.com/17ca7eab6c3e8379f2cb1fea3b99a98cb3df9abf9525d5ebebfbbd09080a2989/68747470733a2f2f706f7365722e707567782e6f72672f69747374727563747572652f6c61726176656c2d6d756c74692d6d656e752f6c6963656e7365)](https://packagist.org/packages/itstructure/laravel-multi-menu)[![Total Downloads](https://camo.githubusercontent.com/53e222be9e1e3fc3d3972e354fa58cef96ba5c2b4ed4ce3f589f1cc3dee59611/68747470733a2f2f706f7365722e707567782e6f72672f69747374727563747572652f6c61726176656c2d6d756c74692d6d656e752f646f776e6c6f616473)](https://packagist.org/packages/itstructure/laravel-multi-menu)[![Build Status](https://camo.githubusercontent.com/31d5e628629da81764970fc7ea5169a9f268979a9adb35331a23028b65a603bb/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f69747374727563747572652f6c61726176656c2d6d756c74692d6d656e752f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/itstructure/laravel-multi-menu/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0d1ef9888eacea50c1cbd617f05008e620397518134322eea1007c5e05320bba/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f69747374727563747572652f6c61726176656c2d6d756c74692d6d656e752f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/itstructure/laravel-multi-menu/?branch=master)

This widget is to display a multi level menu. There can be nested sub-menus. Used for Laravel framework.

The widget uses data from the **database**, in which there are, in addition to the primary keys, also the parent keys.

Data from the **database** is taken from a model and must be instance of **Illuminate\\Database\\Eloquent\\Collection**.

[![Multi level menu example scheme](https://github.com/itstructure/laravel-multi-menu/raw/master/ML_menu_en.jpg)](https://github.com/itstructure/laravel-multi-menu/blob/master/ML_menu_en.jpg)

2 Requirements
--------------

[](#2-requirements)

- laravel 5.5+ | 6+ | 7+ | 8+ | 9+ | 10+ | 11+ | 12+ | 13+
- php &gt;= 7.1.0
- composer

3 Installation
--------------

[](#3-installation)

### 3.1 General from remote repository

[](#31-general-from-remote-repository)

Via composer:

`composer require itstructure/laravel-multi-menu "~2.0.10"`

### 3.2 If you are testing this package from local server directory

[](#32-if-you-are-testing-this-package-from-local-server-directory)

In application `composer.json` file set the repository, like in example:

```
"repositories": [
    {
        "type": "path",
        "url": "../laravel-multi-menu",
        "options": {
            "symlink": true
        }
    }
],
```

Here,

**../laravel-multi-menu** - directory name, which has the same directory level as application and contains multi menu package.

Then run command:

`composer require itstructure/laravel-multi-menu:dev-master --prefer-source`

### 3.3 Publish in application

[](#33-publish-in-application)

- To publish all parts run command:

    `php artisan multimenu:publish`
- To publish only config run command:

    `php artisan multimenu:publish --only=config`

    It stores `multimenu.php` config file to `config` folder.
- To publish only views run command:

    `php artisan multimenu:publish --only=views`

    It stores view files to `resources/views/vendor/multimenu` folder.
- Else you can use `--force` argument to rewrite already published files.

Or another variant:

`php artisan vendor:publish --provider="Itstructure\MultiMenu\MultiMenuServiceProvider"`

4 Usage
-------

[](#4-usage)

### 4.1 Simple variant

[](#41-simple-variant)

#### Config part

[](#config-part)

```
return [
    'primaryKeyName' => 'id', // Editable
    'parentKeyName' => 'parent_id', // Editable
    'mainTemplate' => 'main', // Editable
    'itemTemplate' => 'item', // Editable
];
```

#### View template part

[](#view-template-part)

```
@php
$multiOptions = [ // Editable
    'config' => config('multimenu'),
    'data' => $pages
];
@endphp
```

```
@multiMenu($multiOptions)
```

Here, `$pages` - is from controller part, for example `$pages = Page::all();`. Must be instance of `Illuminate\Database\Eloquent\Collection`.

### 4.2 Addition config options and data

[](#42-addition-config-options-and-data)

#### Config part

[](#config-part-1)

There is an example to set item blade templates for 3 levels:

```
return [
    'primaryKeyName' => 'id',
    'parentKeyName' => 'parent_id',
    'mainTemplate' => 'main',
    'itemTemplate' => [
        'levels' => [
            'item',
            'item',
            'item_new',
        ]
    ],
];
```

You can set `mainTemplate` by analogy.

#### Blade templates

[](#blade-templates)

Example of a custom changed blade template file `item.blade`:

```

        Initial item Id {{ $data->id }} {{ isset($addition) ? ' | ' . $addition : '' }}

```

Example of a custom changed blade template file `item_new.blade`:

```

        New item Id {{ $data->id }} {{ isset($addition) ? ' | ' . $addition : '' }}

```

#### Addition data

[](#addition-data)

Example in a template file:

```
@php
$multiOptions = [
    'config' => config('multimenu'),
    'data' => $pages,
    'additionData' => [
        'levels' => [
            0 => [],
            1 => ['addition' => 'addition string']
        ]
    ]
];
@endphp
```

```
@multiMenu($multiOptions)
```

### 4.3 Database table structure example

[](#43-database-table-structure-example)

`Table "catalogs"`

```
| id  | parent_id |   title    | ... |
|-----|-----------|------------|-----|
|  1  |   NULL    |   item 1   | ... |
|  2  |   NULL    |   item 2   | ... |
|  3  |   NULL    |   item 3   | ... |
|  4  |   NULL    |   item 4   | ... |
|  5  |   NULL    |   item 5   | ... |
|  6  |     2     |  item 2.1  | ... |
|  7  |     2     |  item 2.2  | ... |
|  8  |     7     | item 2.2.1 | ... |
|  9  |     7     | item 2.2.2 | ... |
|  10 |     7     | item 2.2.3 | ... |
| ... |    ...    |     ...    | ... |

```

5 Prevention of collisions
--------------------------

[](#5-prevention-of-collisions)

### 5.1 Before save model

[](#51-before-save-model)

To prevent the entry of the wrong parent identifier (for example, the new number that is a child in a subordinate chain of nested records):

Use static method `checkNewParentId(Model $mainModel, int $newParentId... e.t.c)`

Here are the required parameters:

**$mainModel** - current model record, in which the parent id will be changed for new value.

**$newParentId** - new parent id, which must be verified.

### 5.2 After delete model

[](#52-after-delete-model)

To prevent breaks in the chain of subject submissions:

Use static method `afterDeleteMainModel(Model $mainModel... e.t.c)`

Here is the required parameter:

**$mainModel** - deleted model record.

This function will rebuild the chain.

License
-------

[](#license)

Copyright © 2018-2026 Andrey Girnik .

Licensed under the [MIT license](http://opensource.org/licenses/MIT). See LICENSE.txt for details.

###  Health Score

43

—

FairBetter than 90% of packages

Maintenance74

Regular maintenance activity

Popularity15

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity65

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~203 days

Recently: every ~352 days

Total

13

Last Release

486d ago

Major Versions

1.0.2 → 2.0.02020-07-13

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/31563329?v=4)[Andrey Girnik](/maintainers/itstructure)[@itstructure](https://github.com/itstructure)

---

Top Contributors

[![itstructure](https://avatars.githubusercontent.com/u/31563329?v=4)](https://github.com/itstructure "itstructure (14 commits)")

---

Tags

laravelmenumultilevel-menularavelmenuwidget

### Embed Badge

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

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

###  Alternatives

[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17818.7k](/packages/markwalet-nova-modal-response)[creasi/laravel-nusa

A Laravel package that aim to provide Indonesia' Administrative Data

997.7k2](/packages/creasi-laravel-nusa)[team-nifty-gmbh/tall-datatables

Server-side rendered datatables for Laravel and Livewire

1319.7k3](/packages/team-nifty-gmbh-tall-datatables)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.2k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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