燈絲選單
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