PHPackages                             mgbg/custom-filament-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. mgbg/custom-filament-menu-builder

ActiveLibrary

mgbg/custom-filament-menu-builder
=================================

Custom with fixes - Create and manage menus and menu items

0.5.5(1y ago)018MITPHPPHP ^8.1

Since Oct 3Pushed 1y agoCompare

[ Source](https://github.com/mgbg/custom-filament-menu-builder)[ Packagist](https://packagist.org/packages/mgbg/custom-filament-menu-builder)[ Docs](https://github.com/datlechin/filament-menu-builder)[ GitHub Sponsors](https://github.com/datlechin)[ RSS](/packages/mgbg-custom-filament-menu-builder/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (8)Versions (3)Used By (0)

Filament Menu Builder
=====================

[](#filament-menu-builder)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6ad423cb53074527898ea2bafa8c2d9168c6aead593f42ac3e0674974b815718/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6461746c656368696e2f66696c616d656e742d6d656e752d6275696c6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/datlechin/filament-menu-builder)[![Total Downloads](https://camo.githubusercontent.com/bfdd215b5e54648ec9a1514751abe23c07d7ccb31cb7d15931e08ffe2c1d8cba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6461746c656368696e2f66696c616d656e742d6d656e752d6275696c6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/datlechin/filament-menu-builder)

This [Filament](https://filamentphp.com) package allows you to create and manage menus in your Filament application.

[![Filament Menu Builder](https://github.com/datlechin/filament-menu-builder/raw/main/art/menu-builder.jpg)](https://github.com/datlechin/filament-menu-builder/raw/main/art/menu-builder.jpg)

Note

I created this for my personal project, so some features and extensibility are still lacking. Pull requests are welcome.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require datlechin/filament-menu-builder
```

You need to publish the migrations and run them:

```
php artisan vendor:publish --tag="filament-menu-builder-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="filament-menu-builder-config"
```

Optionally, if you want to customize the views, you can publish them with:

```
php artisan vendor:publish --tag="filament-menu-builder-views"
```

This is the contents of the published config file:

```
return [
    'tables' => [
        'menus' => 'menus',
        'menu_items' => 'menu_items',
        'menu_locations' => 'menu_locations',
    ],
];
```

Add the plugin to `AdminPanelProvider`:

```
use Datlechin\FilamentMenuBuilder\FilamentMenuBuilderPlugin;

$panel
    ...
    ->plugin(FilamentMenuBuilderPlugin::make())
```

Usage
-----

[](#usage)

### Adding locations

[](#adding-locations)

Locations are the places where you can display menus in the frontend. You can add locations in the `AdminPanelProvider`:

```
use Datlechin\FilamentMenuBuilder\FilamentMenuBuilderPlugin;

$panel
    ...
    ->plugin(
        FilamentMenuBuilderPlugin::make()
            ->addLocation('header', 'Header')
            ->addLocation('footer', 'Footer')
    )
```

The first argument is the key of the location, and the second argument is the title of the location.

Alternatively, you may add locations using an array:

```
use Datlechin\FilamentMenuBuilder\FilamentMenuBuilderPlugin;

$panel
    ...
    ->plugin(
        FilamentMenuBuilderPlugin::make()
            ->addLocations([
                'header' => 'Header',
                'footer' => 'Footer',
            ])
    )
```

### Setting up Menu Panels

[](#setting-up-menu-panels)

Menu panels are the panels that contain the menu items which you can add to the menus.

#### Custom Menu Panel

[](#custom-menu-panel)

By default, the package provides a **Custom Link** menu panel that allows you to add custom links to the menus.

[![Custom Link Menu Panel](https://github.com/datlechin/filament-menu-builder/raw/main/art/custom-link.png)](https://github.com/datlechin/filament-menu-builder/raw/main/art/custom-link.png)

#### Static Menu Panel

[](#static-menu-panel)

The static menu panel allows you to add menu items manually.

```
use Datlechin\FilamentMenuBuilder\FilamentMenuBuilderPlugin;
use Datlechin\FilamentMenuBuilder\MenuPanel\StaticMenuPanel;

$panel
    ...
    ->plugin(
        FilamentMenuBuilderPlugin::make()
            ->addMenuPanels([
                StaticMenuPanel::make()
                    ->add('Home', url('/'))
                    ->add('Blog', url('/blog')),
            ])
    )
```

Similarily to locations, you may also add static menu items using an array:

```
use Datlechin\FilamentMenuBuilder\FilamentMenuBuilderPlugin;
use Datlechin\FilamentMenuBuilder\MenuPanel\StaticMenuPanel;

$panel
    ...
    ->plugin(
        FilamentMenuBuilderPlugin::make()
            ->addMenuPanels([
                StaticMenuPanel::make()
                    ->addMany([
                        'Home' => url('/'),
                        'Blog' => url('/blog'),
                    ])
            ])
    )
```

[![Static Menu Panel](https://github.com/datlechin/filament-menu-builder/raw/main/art/static-menu.png)](https://github.com/datlechin/filament-menu-builder/raw/main/art/static-menu.png)

#### Model Menu Panel

[](#model-menu-panel)

The model menu panel allows you to add menu items from a model.

To create a model menu panel, your model must implement the `\Datlechin\FilamentMenuBuilder\Contracts\MenuPanelable` interface and `\Datlechin\FilamentMenuBuilder\Concerns\HasMenuPanel` trait.

Then you will need to implement the following methods:

```
use Illuminate\Database\Eloquent\Model;
use Datlechin\FilamentMenuBuilder\Contracts\MenuPanelable;

class Category extends Model implements MenuPanelable
{
    public function getMenuPanelTitleColumn(): string
    {
        return 'name';
    }

    public function getMenuPanelUrlUsing(): callable
    {
        return fn (self $model) => route('categories.show', $model->slug);
    }
}
```

Then you can add the model menu panel to the plugin:

```
use Datlechin\FilamentMenuBuilder\FilamentMenuBuilderPlugin;
use Datlechin\FilamentMenuBuilder\MenuPanel\ModelMenuPanel;

$panel
    ...
    ->plugin(
        FilamentMenuBuilderPlugin::make()
            ->addMenuPanels([
                ModelMenuPanel::make()
                    ->model(\App\Models\Category::class),
            ])
    )
```

[![Model Menu Panel](https://github.com/datlechin/filament-menu-builder/raw/main/art/model-menu.png)](https://github.com/datlechin/filament-menu-builder/raw/main/art/model-menu.png)

#### Additional Menu Panel Options

[](#additional-menu-panel-options)

When registering a menu panel, multiple methods are available allowing you to configure the panel's behavior such as collapse state and pagination.

```
use Datlechin\FilamentMenuBuilder\FilamentMenuBuilderPlugin;
use Datlechin\FilamentMenuBuilder\MenuPanel\StaticMenuPanel;

$panel
    ...
    ->plugin(
        FilamentMenuBuilderPlugin::make()
            ->addMenuPanels([
                StaticMenuPanel::make()
                    ->addMany([
                        ...
                    ])
                    ->description('Lorem ipsum...')
                    ->icon('heroicon-m-link')
                    ->collapsed(true)
                    ->collapsible(true)
                    ->paginate(perPage: 5, condition: true)
            ])
    )
```

### Custom Fields

[](#custom-fields)

In some cases, you may want to extend menu and menu items with custom fields. To do this, start by passing an array of form components to the `addMenuFields` and `addMenuItemFields` methods when registering the plugin:

```
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Datlechin\FilamentMenuBuilder\FilamentMenuBuilderPlugin;

$panel
    ...
    ->plugin(
        FilamentMenuBuilderPlugin::make()
            ->addMenuFields([
                Toggle::make('is_logged_in'),
            ])
            ->addMenuItemFields([
                TextInput::make('classes'),
            ])
    )
```

Next, create a migration adding the additional columns to the appropriate tables:

```
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table(config('filament-menu-builder.tables.menus'), function (Blueprint $table) {
            $table->boolean('is_logged_in')->default(false);
        });

        Schema::table(config('filament-menu-builder.tables.menu_items'), function (Blueprint $table) {
            $table->string('classes')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table(config('filament-menu-builder.tables.menus'), function (Blueprint $table) {
            $table->dropColumn('is_logged_in');
        });

        Schema::table(config('filament-menu-builder.tables.menu_items'), function (Blueprint $table) {
            $table->dropColumn('classes');
        });
    }
}
```

Once done, simply run `php artisan migrate`.

### Customizing the Resource

[](#customizing-the-resource)

Out of the box, a default Menu Resource is registered with Filament when registering the plugin in the admin provider. This resource can be extended and overridden allowing for more fine-grained control.

Start by extending the `Datlechin\FilamentMenuBuilder\Resources\MenuResource` class in your application. Below is an example:

```
namespace App\Filament\Plugins\Resources;

use Datlechin\FilamentMenuBuilder\Resources\MenuResource as BaseMenuResource;

class MenuResource extends BaseMenuResource
{
    protected static ?string $navigationGroup = 'Navigation';

    public static function getNavigationBadge(): ?string
    {
        return number_format(static::getModel()::count());
    }
}
```

Now pass the custom resource to `usingResource` while registering the plugin with the panel:

```
use App\Filament\Plugins\Resources\MenuResource;
use Datlechin\FilamentMenuBuilder\FilamentMenuBuilderPlugin;

$panel
    ...
    ->plugin(
        FilamentMenuBuilderPlugin::make()
            ->usingResource(MenuResource::class)
    )
```

### Customizing the Models

[](#customizing-the-models)

The default models used by the plugin can be configured and overridden similarly to the plugin resource as seen above.

Simply extend the default models and then pass the classes when registering the plugin in the panel:

```
use App\Models\Menu;
use App\Models\MenuItem;
use App\Models\MenuLocation;
use Datlechin\FilamentMenuBuilder\FilamentMenuBuilderPlugin;

$panel
    ...
    ->plugin(
        FilamentMenuBuilderPlugin::make()
            ->usingMenuModel(Menu::class)
            ->usingMenuItemModel(MenuItem::class)
            ->usingMenuLocationModel(MenuLocation::class)
    )
```

### Using Menus

[](#using-menus)

Getting the assigned menu for a registered location can be done using the `Menu` model. Below we will call the menu assigned to the `primary` location:

```
use Datlechin\FilamentMenuBuilder\Models\Menu;

$menu = Menu::location('primary');
```

Menu items can be iterated from the `menuItems` relationship:

```
@foreach ($menu->menuItems as $item)
    {{ $item->title }}
@endforeach
```

When a menu item is a parent, a collection of the child menu items will be available on the `children` property:

```
@foreach ($menu->menuItems as $item)
    {{ $item->title }}

    @if ($item->children)
        @foreach ($item->children as $child)
            {{ $child->title }}
        @endforeach
    @endif
@endforeach
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](https://github.com/datlechin/filament-menu-builder/raw/main/CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/datlechin/filament-menu-builder/raw/main/.github/CONTRIBUTING.md) for details.

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

[](#security-vulnerabilities)

Please review [our security policy](https://github.com/datlechin/filament-menu-builder/security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Ngo Quoc Dat](https://github.com/datlechin)
- [Log1x](https://github.com/Log1x)
- [All Contributors](https://github.com/datlechin/filament-menu-builder/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/datlechin/filament-menu-builder/raw/main/LICENSE.md) for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~0 days

Total

2

Last Release

584d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3c4e9d40209ae6425100552bde050e902cd8b17bde040f686e77b3e380047e04?d=identicon)[dyanakiev](/maintainers/dyanakiev)

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

---

Top Contributors

[![datlechin](https://avatars.githubusercontent.com/u/56961917?v=4)](https://github.com/datlechin "datlechin (70 commits)")[![Log1x](https://avatars.githubusercontent.com/u/5745907?v=4)](https://github.com/Log1x "Log1x (58 commits)")[![depfu[bot]](https://avatars.githubusercontent.com/in/715?v=4)](https://github.com/depfu[bot] "depfu[bot] (6 commits)")[![dyanakiev](https://avatars.githubusercontent.com/u/11967079?v=4)](https://github.com/dyanakiev "dyanakiev (3 commits)")[![bdsumon4u](https://avatars.githubusercontent.com/u/75123992?v=4)](https://github.com/bdsumon4u "bdsumon4u (2 commits)")[![ImgBotApp](https://avatars.githubusercontent.com/u/31427850?v=4)](https://github.com/ImgBotApp "ImgBotApp (1 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

laraveldatlechinfilament-menu-builder

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/mgbg-custom-filament-menu-builder/health.svg)

```
[![Health](https://phpackages.com/badges/mgbg-custom-filament-menu-builder/health.svg)](https://phpackages.com/packages/mgbg-custom-filament-menu-builder)
```

###  Alternatives

[datlechin/filament-menu-builder

Create and manage menus and menu items

13550.3k2](/packages/datlechin-filament-menu-builder)[joaopaulolndev/filament-edit-profile

Filament package to edit profile

250258.1k34](/packages/joaopaulolndev-filament-edit-profile)[guava/filament-knowledge-base

A filament plugin that adds a knowledge base and help to your filament panel(s).

206120.5k1](/packages/guava-filament-knowledge-base)[marcelweidum/filament-expiration-notice

Customize the livewire expiration notice

9169.0k4](/packages/marcelweidum-filament-expiration-notice)[guava/filament-modal-relation-managers

Allows you to embed relation managers inside filament modals.

7565.0k4](/packages/guava-filament-modal-relation-managers)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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