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

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

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

bambamboole/filament-menu

最新稳定版本:0.3.0

Composer 安装命令:

composer require bambamboole/filament-menu

包简介

Create menus with ease in Filament

README 文档

README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

A menu builder plugin for Filament that lets you create and manage navigation menus with drag-and-drop ordering, nesting, and linkable Eloquent models.

Installation

composer require bambamboole/filament-menu

Usage

Register the plugin in your panel provider:

use Bambamboole\FilamentMenu\FilamentMenuPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            FilamentMenuPlugin::make()
                ->locations(['header', 'footer', 'sidebar'])
                ->linkables([Page::class, Post::class])
                ->canAccess(fn () => auth()->user()->isAdmin())
                ->cacheFor(3600),
        ]);
}
Method Description
locations(array) Named positions where menus can be assigned (e.g. header, footer)
linkables(array) Eloquent models that can be linked as menu items
canAccess(Closure) Controls who can manage menus
cacheFor(int) Cache duration in seconds (auto-invalidated on changes)

Linkable Models

To let editors link menu items to your Eloquent models, implement the Linkable interface:

use Bambamboole\FilamentMenu\Contracts\Linkable;
use Bambamboole\FilamentMenu\Concerns\IsLinkable;
use Illuminate\Database\Eloquent\Builder;

class Page extends Model implements Linkable
{
    use IsLinkable;

    public static function getLinkableQuery(): Builder
    {
        return static::query()->where('published', true);
    }

    public static function getNameColumn(): string
    {
        return 'title';
    }

    public function getLink(): string
    {
        return route('pages.show', $this->slug);
    }
}

The IsLinkable trait provides sensible defaults — override only what you need.

Rendering Menus

Use the Blade component in your templates:

<x-filament-menu::menu location="header" />

<x-filament-menu::menu slug="main-navigation" />

Or retrieve menus programmatically:

use Bambamboole\FilamentMenu\Models\Menu;

$menu = Menu::findByLocation('header');
$tree = $menu->getTree(); // array of nested items

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 689
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 5
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固