Download the PHP package datlechin/filament-menu-builder without Composer
On this page you can find all versions of the php package datlechin/filament-menu-builder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download datlechin/filament-menu-builder
More information about datlechin/filament-menu-builder
Files in datlechin/filament-menu-builder
Package filament-menu-builder
Short Description Create and manage menus and menu items
License MIT
Homepage https://github.com/datlechin/filament-menu-builder
Informations about the package filament-menu-builder
Filament Menu Builder
This Filament package allows you to create and manage menus in your Filament application.
[!NOTE] I created this for my personal project, so some features and extensibility are still lacking. Pull requests are welcome.
Installation
You can install the package via composer:
You need to publish the migrations and run them:
You can publish the config file with:
Optionally, if you want to customize the views, you can publish them with:
This is the contents of the published config file:
Add the plugin to AdminPanelProvider
:
Usage
Adding locations
Locations are the places where you can display menus in the frontend. You can add locations in the AdminPanelProvider
:
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:
Setting up Menu Panels
Menu panels are the panels that contain the menu items which you can add to the menus.
Custom Link Menu Panel
By default, the package provides a Custom Link menu panel that allows you to add custom links to the menus.
The panel can be disabled by using the following when configuring the plugin, should you not need this functionality.
Custom Text Menu Panel
This package provides a Custom Text menu panel that allows you to add custom text items to the menus.
It is identical to the Custom Link menu panel except for the fact that you only set a title without a URL or target. This can be useful to add headers to mega-style menus.
The panel is disabled by default to prevent visual clutter. To enable the Custom Text menu panel, you can use the following when configuring the plugin.
Static Menu Panel
The static menu panel allows you to add menu items manually.
Similarily to locations, you may also add static menu items using an array:
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 must also implement the getMenuPanelTitleColumn
and getMenuPanelUrlUsing
methods. A complete example of this implementation is as follows:
Then you can add the model menu panel to the plugin:
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.
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:
Next, create a migration adding the additional columns to the appropriate tables:
Once done, simply run php artisan migrate
.
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:
Now pass the custom resource to usingResource
while registering the plugin with the panel:
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:
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:
Menu items can be iterated from the menuItems
relationship:
When a menu item is a parent, a collection of the child menu items will be available on the children
property:
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.
All versions of filament-menu-builder with dependencies
filament/filament Version ^3.0
spatie/laravel-package-tools Version ^1.15.0