PHPackages                             marshmallow/nova-4-menu-builder - 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. marshmallow/nova-4-menu-builder

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

marshmallow/nova-4-menu-builder
===============================

This Laravel Nova package allows you to create and manage menus and menu items.

v8.0.0(10mo ago)02.4k↓60%MITPHPPHP &gt;=8.0CI failing

Since Jan 7Pushed 3w ago2 watchersCompare

[ Source](https://github.com/marshmallow-packages/nova-4-menu-builder)[ Packagist](https://packagist.org/packages/marshmallow/nova-4-menu-builder)[ GitHub Sponsors](https://github.com/marshmallow)[ RSS](/packages/marshmallow-nova-4-menu-builder/feed)WikiDiscussions main Synced yesterday

READMEChangelog (4)Dependencies (6)Versions (8)Used By (0)

[![alt text](https://camo.githubusercontent.com/f5450f299f5713ce2f04dd5a1ba7ce9960ed4568b3574e4c4ee3cddc75477253/68747470733a2f2f6d617273686d616c6c6f772e6465762f63646e2f6d656469612f6c6f676f2d7265642d3233377834362e706e67 "marshmallow.")](https://camo.githubusercontent.com/f5450f299f5713ce2f04dd5a1ba7ce9960ed4568b3574e4c4ee3cddc75477253/68747470733a2f2f6d617273686d616c6c6f772e6465762f63646e2f6d656469612f6c6f676f2d7265642d3233377834362e706e67)

Nova 4 Menu Builder
===================

[](#nova-4-menu-builder)

[![Latest Version on Packagist](https://camo.githubusercontent.com/35a4da6a34320b9c02985ebb65af6ebff7be0b22ec1e783a741ef85f87fb1493/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d617273686d616c6c6f772f6e6f76612d342d6d656e752d6275696c6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marshmallow/nova-4-menu-builder)[![Total Downloads](https://camo.githubusercontent.com/55526a092bb143d553ed5c1587c8d22878d7bcdc5718e33474c1c9b62609c16d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d617273686d616c6c6f772f6e6f76612d342d6d656e752d6275696c6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marshmallow/nova-4-menu-builder)

This [Laravel Nova](https://nova.laravel.com/) package allows you to create and manage menus and menu items.

Important

This package was originally forked from [outl1ne/nova-menu-builder](https://github.com/outl1ne/nova-menu-builder). Since we were making many opinionated changes, we decided to continue development in our own version rather than submitting pull requests that might not benefit all users of the original package. You're welcome to use this package, we're actively maintaining it. If you encounter any issues, please don't hesitate to reach out.

Requirements
------------

[](#requirements)

- `php: >=8.0`
- `laravel/nova: ^5.0`

This package also depends on `doctrine/dbal` and `outl1ne/nova-translations-loader`, which are installed automatically.

Features
--------

[](#features)

- Menu management
- Menu items management
    - Simple drag-and-drop nesting and re-ordering
- Custom menu item types support
    - Ability to easily add select types
    - Ability to add custom fields
    - Use the `menubuilder:type` command to easily create new types
- Fully localizable

Installation and Setup
----------------------

[](#installation-and-setup)

### Installing the package

[](#installing-the-package)

Install the package in a Laravel Nova project via Composer, edit the configuration file and run migrations.

```
# Install the package
composer require marshmallow/nova-4-menu-builder

# Publish the configuration file and edit it to your preference
# NB! If you want custom table names, configure them before running the migrations.
php artisan vendor:publish --tag=nova-menu-builder-config
```

Register the tool with Nova in the `tools()` method of the `NovaServiceProvider`:

```
// in app/Providers/NovaServiceProvider.php

public function tools()
{
    return [
        // ...
        \Marshmallow\MenuBuilder\MenuBuilder::make()
            // Optional customization
            ->title('Menus')        // Define a new name for the sidebar item
            ->icon('adjustments')   // Customize the menu icon, supports heroicons
            ->hideMenu(false),      // Hide the MenuBuilder-defined MenuSection
    ];
}
```

### Setting up

[](#setting-up)

After publishing the configuration file, you have to make some changes in the config:

```
# Choose table names of your liking by editing the two key/values:
'menus_table_name' => 'nova_menu_menus',
'menu_items_table_name' => 'nova_menu_menu_items',

# Define the locales for your project:
# If your project doesn't have localization, you can just leave it as it is.
# When there's just one locale, anything related to localization isn't displayed.
'locales' => ['en_US' => 'English'],

# Define the list of possible menus (ie 'footer', 'header', 'main-menu').
# The package ships with 'header' and 'footer' as examples:
'menus' => [
    'header' => [
        'name' => 'Header',
        'unique' => true,
        'max_depth' => 10,
        'menu_item_types' => [],
    ],
    'footer' => [
        'name' => 'Footer',
        'unique' => true,
        'max_depth' => 10,
        'menu_item_types' => [],
    ],
],

# Register the menu item types that can be selected when creating menu items.
# The package ships with a text type and a static URL type by default:
'menu_item_types' => [
    \Marshmallow\MenuBuilder\MenuItemTypes\MenuItemTextType::class,
    \Marshmallow\MenuBuilder\MenuItemTypes\MenuItemStaticURLType::class,
],
```

Next, just run the migrations and you're set.

```
# Run the automatically loaded migrations
php artisan migrate
```

### Optionally publish migrations

[](#optionally-publish-migrations)

This is only useful if you want to overwrite migrations and models. If you wish to use the menu builder as it comes out of the box, you don't need them.

```
# Publish migrations to overwrite them (optional)
php artisan vendor:publish --tag=nova-menu-builder-migrations
```

Configuration
-------------

[](#configuration)

The published config file lives at `config/nova-menu.php`. The available options are:

KeyDefaultDescription`menus_table_name``'nova_menu_menus'`Table name used to store menus.`menu_items_table_name``'nova_menu_menu_items'`Table name used to store menu items.`menus_table_connection``null`Override the database connection used for menu validation. Uses the default connection when `null`.`locales``['en_US' => 'English']`Available locales as `[key => name]` pairs, a closure or a callable.`menus``['header' => ..., 'footer' => ...]`The menus that can be managed, keyed by slug. Each menu supports `name`, `unique`, `max_depth` and `menu_item_types`.`menu_item_types``[MenuItemTextType, MenuItemStaticURLType]`The menu item types available when creating menu items.`show_duplicate``true`Show the duplicate action on menu items.`collapsed_as_default``true`Collapse nested menu items by default.`controller``MenuController::class`Optionally override the menu controller.`resource``MenuResource::class`Optionally override the Nova menu resource.`menu_model``Menu::class`Optionally override the menu model.`menu_item_model``MenuItem::class`Optionally override the menu item model.`auto_load_migrations``true`Auto-load the package migrations without publishing them.Usage
-----

[](#usage)

### Locales configuration

[](#locales-configuration)

You can define the locales for the menus in the config file, as shown below.

```
// in config/nova-menu.php

return [
  // ...
  'locales' => [
    'en' => 'English',
    'et' => 'Estonian',
  ],

  // or using a closure (not cacheable):

  'locales' => function() {
    return nova_lang_get_locales();
  },

  // or if you want to use a function, but still be able to cache it:

  'locales' => '\App\Configuration\NovaMenuConfiguration@getLocales',

  // or

  'locales' => 'nova_lang_get_locales',
  // ...
];
```

### Custom menu item types

[](#custom-menu-item-types)

Menu builder allows you to create custom menu item types with custom fields.

You can scaffold a new type with the included Artisan command:

```
php artisan menubuilder:type
```

Alternatively, create a class that extends the `Marshmallow\MenuBuilder\MenuItemTypes\BaseMenuItemType` class and register it in the config file.

```
// in config/nova-menu.php

return [
  // ...
  'menu_item_types' => [
    \App\MenuItemTypes\CustomMenuItemType::class,
  ],
  // ...
];
```

In the created class, overwrite the following methods:

```
/**
 * Get the menu link identifier that can be used to tell different custom
 * links apart (ie 'page' or 'product').
 *
 * @return string
 **/
public static function getIdentifier(): string {
    // Example usecase
    // return 'page';
    return '';
}

/**
 * Get menu link name shown in  a dropdown in CMS when selecting link type
 * ie ('Product Link').
 *
 * @return string
 **/
public static function getName(): string {
    // Example usecase
    // return 'Page Link';
    return '';
}

/**
 * Get list of options shown in a select dropdown.
 *
 * Should be a map of [key => value, ...], where key is a unique identifier
 * and value is the displayed string.
 *
 * @return array
 **/
public static function getOptions($locale): array {
    // Example usecase
    // return Page::all()->pluck('name', 'id')->toArray();
    return [];
}

/**
 * Get the subtitle value shown in CMS menu items list.
 *
 * @param $value
 * @param $data The data from item fields.
 * @param $locale
 * @return string
 **/
public static function getDisplayValue($value, ?array $data, $locale) {
    // Example usecase
    // return 'Page: ' . Page::find($value)->name;
    return $value;
}

/**
 * Get the enabled value
 *
 * @param $value
 * @param $data The data from item fields.
 * @param $locale
 * @return string
*/
public static function getEnabledValue($value, ?array $data, $locale)
{
  return true;
}

/**
 * Get the value of the link visible to the front-end.
 *
 * Can be anything. It is up to you how you will handle parsing it.
 *
 * This will only be called when using the nova_get_menu()
 * and nova_get_menus() helpers or when you call formatForAPI()
 * on the Menu model.
 *
 * @param $value The key from options list that was selected.
 * @param $data The data from item fields.
 * @param $locale
 * @return any
 */
public static function getValue($value, ?array $data, $locale)
{
    return $value;
}

/**
 * Get the fields displayed by the resource.
 *
 * @return array An array of fields.
 */
public static function getFields(): array
{
    return [];
}

/**
 * Get the rules for the resource.
 *
 * @return array A key-value map of attributes and rules.
 */
public static function getRules(): array
{
    return [];
}

/**
 * Get data of the link visible to the front-end.
 *
 * Can be anything. It is up to you how you will handle parsing it.
 *
 * This will only be called when using the nova_get_menu()
 * and nova_get_menus() helpers or when you call formatForAPI()
 * on the Menu model.
 *
 * @param null $data Field values
 * @return any
 */
public static function getData($data = null)
{
    return $data;
}
```

### Returning the menus in a JSON API

[](#returning-the-menus-in-a-json-api)

#### nova\_get\_menus()

[](#nova_get_menus)

A helper function `nova_get_menus` is globally registered in this package which returns all the menus including their menu items in an API friendly format.

```
public function getMenus(Request $request) {
    $menusResponse = nova_get_menus();
    return response()->json($menusResponse);
}
```

#### Get single menu via identifier

[](#get-single-menu-via-identifier)

```
// Available helpers
nova_get_menu_by_slug($menuSlug, $locale = null)
nova_get_menu_by_id($menuId, $locale = null)
```

To get a single menu, you can use the available helper functions.
Returns null if no menu with the identifier is found or returns the menu if it is found. If no locale is passed, the helper will automatically choose the first configured locale.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for recent changes.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please report security vulnerabilities by email to  rather than via the public issue tracker.

Credits
-------

[](#credits)

- [Tarvo Reinpalu](https://github.com/Tarpsvo)
- [Eric Lagarda (original nova-menu-builder)](https://github.com/Krato)
- [Ralph Huwiler (vue-nestable)](https://github.com/rhwilr)
- [outl1ne/nova-menu-builder](https://github.com/outl1ne/nova-menu-builder)
- [All Contributors](https://github.com/marshmallow-packages/nova-4-menu-builder/contributors)

License
-------

[](#license)

Nova Menu Builder is open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance77

Regular maintenance activity

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.5% 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 ~58 days

Total

5

Last Release

310d ago

Major Versions

v7.4.0 → v8.0.02025-08-27

### Community

Maintainers

![](https://www.gravatar.com/avatar/be33d2624e24c516e73892b0929447cc762f3622c024ab8d0d2a59042e5d2c7f?d=identicon)[marshmallow](/maintainers/marshmallow)

---

Top Contributors

[![LTKort](https://avatars.githubusercontent.com/u/2412670?v=4)](https://github.com/LTKort "LTKort (20 commits)")[![stefvanesch](https://avatars.githubusercontent.com/u/46725619?v=4)](https://github.com/stefvanesch "stefvanesch (12 commits)")

---

Tags

laravelbuildermenunova

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/marshmallow-nova-4-menu-builder/health.svg)

```
[![Health](https://phpackages.com/badges/marshmallow-nova-4-menu-builder/health.svg)](https://phpackages.com/packages/marshmallow-nova-4-menu-builder)
```

###  Alternatives

[optimistdigital/nova-sortable

This Laravel Nova package allows you to reorder models in a Nova resource's index view using drag &amp; drop.

2852.1M6](/packages/optimistdigital-nova-sortable)[outl1ne/nova-sortable

This Laravel Nova package allows you to reorder models in a Nova resource's index view using drag &amp; drop.

2862.1M9](/packages/outl1ne-nova-sortable)[optimistdigital/nova-menu-builder

This Laravel Nova package allows you to create and manage menus and menu items.

243377.1k](/packages/optimistdigital-nova-menu-builder)[outl1ne/nova-menu-builder

This Laravel Nova package allows you to create and manage menus and menu items.

243268.1k4](/packages/outl1ne-nova-menu-builder)[optimistdigital/nova-multiselect-field

A multiple select field for Laravel Nova.

3453.7M8](/packages/optimistdigital-nova-multiselect-field)[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17878.9k](/packages/markwalet-nova-modal-response)

PHPackages © 2026

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