灯丝菜单
v1.0.7
菜单数据库构建器将其用作灯丝面板上的导航或用作 Livewire 组件
composer require tomatophp/filament-menus
安装软件包后请运行此命令
php artisan filament-menus:install
最后在/app/Providers/Filament/AdminPanelProvider.php
上注册插件
-> plugins (
Filament SpatieLaravelTranslatablePlugin :: make ()-> defaultLocales ([ ' en ' , ' ar ' ])
TomatoPHP FilamentMenus FilamentMenusPlugin :: make ()
)
您可以使用此包作为 Filament 管理面板上的导航
use Filament Navigation NavigationBuilder ;
use Filament Navigation NavigationGroup ;
use TomatoPHP FilamentMenus FilamentMenuLoader ;
$ panel -> navigation ( function ( NavigationBuilder $ builder ){
return $ builder
// Use Inside Group
-> groups ([
NavigationGroup :: make ()
-> label ( ' Dashboard ' )
-> items ( FilamentMenuLoader :: make ( ' dashboard ' )),
])
// Use Directly
-> items ( FilamentMenuLoader :: make ( ' dashboard ' ));
})
其中dashboard
是菜单键。
进入路由admin/menus
并创建一个新菜单,您将获得livewire组件的代码
您只需使用此命令作为 livewire 组件即可构建菜单
">< x-filament-menu menu = " header " />
其中header
是菜单的键,您将在菜单表列表中准备好代码
您可以使用自定义视图例如:
">< x-filament-menu menu = " header " view = " menu-item " />
默认情况下,我们使用 Tailwind 作为此代码的主视图
@foreach ( $menuItems as $item )
< a class = " text-gray-500 " href = " {{ $item [ ' url ' ] } } " @if ( $item [ ' blank ' ] ) target = " _blank " @endif >
< span class = " flex justify-between " >
@if ( isset ( $item [ ' icon ' ]) && ! empty ( $item [ ' icon ' ]) )
< x-icon class = " w-4 h-4 mx-2 " name = " {{ $item [ ' icon ' ] } } " > x-icon >
@endif
{{ $item [ ' title ' ] } }
span >
a >
@endforeach
或者您可以使用直接帮助menu($key)
来获取菜单项
@foreach ( menu ( ' header ' ) as $item )
< a class = " text-gray-500 " href = " {{ $item [ ' url ' ] } } " @if ( $item [ ' blank ' ] ) target = " _blank " @endif >
< span class = " flex justify-between " >
@if ( isset ( $item [ ' icon ' ]) && ! empty ( $item [ ' icon ' ]) )
< x-icon class = " w-4 h-4 mx-2 " name = " {{ $item [ ' icon ' ] } } " > x-icon >
@endif
{{ $item [ ' title ' ] } }
span >
a >
@endforeach
您可以使用此命令发布配置文件
php artisan vendor:publish --tag= " filament-menus-config "
您可以使用此命令发布视图文件
php artisan vendor:publish --tag= " filament-menus-views "
您可以使用此命令发布语言文件
php artisan vendor:publish --tag= " filament-menus-lang "
您可以使用此命令发布迁移文件
php artisan vendor:publish --tag= " filament-menus-migrations "
查看我们很棒的 TomatoPHP