notebrainslab/filament-menu-manager 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

notebrainslab/filament-menu-manager

Composer 安装命令:

composer require notebrainslab/filament-menu-manager

包简介

A powerful Filament v4 & v5 plugin for managing menus with multiple locations, drag & drop reordering, Eloquent model support, auto-save, and dark theme.

README 文档

README

Latest Version on Packagist License

A powerful Filament v4 & v5 plugin for managing navigation menus with:

  • Multiple Locations — Primary, Footer, Sidebar, or any custom location
  • Drag & Drop Reordering — Powered by SortableJS with nested support
  • Button Reordering — Up ↑ Down ↓ Indent → Outdent ← for accessibility
  • Built-in Panels — Custom Links panel and Eloquent Model Sources panel
  • Eloquent Model Compatible — Add Posts, Pages, or any model as menu items
  • Auto Save — Debounced auto-save on every change (configurable)
  • Dark Theme — Full dark mode support via CSS custom properties

Requirements

Dependency Version
PHP ^8.2
Laravel ^11.0 | ^12.0 | ^13.0
Filament ^4.0 | ^5.0
Livewire ^3.0 | ^4.0

Installation

1. Install via Composer

composer require notebrainslab/filament-menu-manager

2. Publish and run migrations

php artisan filament-menu-manager:install

# Or manually:
php artisan vendor:publish --tag="filament-menu-manager-migrations"
php artisan migrate

3. Register the plugin in your Panel Provider

use NoteBrainsLab\FilamentMenuManager\FilamentMenuManagerPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugin(
            FilamentMenuManagerPlugin::make()
                ->locations([
                    'primary' => 'Primary',
                    'footer' => 'Footer',
                ])
        );
}

Upgrade Guide

Upgrade from v1.0 → v2.0

If you are upgrading from v1.0, run the following commands to install the latest version and publish the updated configuration file.

Step 1: Update the package

composer require notebrainslab/filament-menu-manager:^2.0

Step 2: Republish the configuration

php artisan vendor:publish --tag="filament-menu-manager-config" --force

The --force flag will overwrite your existing configuration file with the latest v2.0 version.

Configuration

Publish the config file (Optional):

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

Publish the resource files (Optional):

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

Plugin API (Fluent)

FilamentMenuManagerPlugin::make()
    ->locations([
        'primary' => 'Primary',
        'footer' => 'Footer',
    ])
    ->modelSources([
        \App\Models\Post::class,
        \App\Models\Page::class,
    ])
    ->navigationGroup('Content')
    ->navigationIcon('heroicon-o-bars-3')
    ->navigationSort(10)
    ->navigationLabel('Menus')
    ->authentication(function () {
        return auth()->user()->can('View:MenuManagerPage');

        // Expected boolean value: true or false
        // Based on your permission matrix
    }),

Eloquent Model Sources

To make an Eloquent model selectable in the Models panel, add the trait:

use NoteBrainsLab\FilamentMenuManager\Concerns\HasMenuItems;

class Post extends Model
{
    use HasMenuItems;

    // Optional: override the defaults

    public function getMenuLabel(): string
    {
        return $this->title;
    }

    public function getMenuUrl(): string
    {
        return route('posts.show', $this);
    }

    public function getMenuTarget(): string
    {
        return '_self';
    }

    public function getMenuIcon(): ?string
    {
        return 'heroicon-o-document';
    }
}

Then register the model in the plugin:

FilamentMenuManagerPlugin::make()
    ->modelSources([
        \App\Models\Post::class,
    ])

Render Menus in Blade

@php
    $manager = app(\NoteBrainsLab\FilamentMenuManager\MenuManager::class);

    $menus = $manager->menusForLocation('primary');

    $menu = $menus->first();

    $tree = $menu?->getTree() ?? [];
@endphp

@foreach($tree as $item)
    <a href="{{ $item['url'] }}"
       target="{{ $item['target'] }}">
        {{ $item['title'] }}
    </a>

    @if(!empty($item['children']))
        {{-- Render child items --}}
    @endif
@endforeach

Testing

composer test

Changelog

See CHANGELOG.md.

License

MIT License. See LICENSE.

统计信息

  • 总下载量: 1.73k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 0
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固