Download the PHP package back1ng/filament-tree without Composer
On this page you can find all versions of the php package back1ng/filament-tree. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download back1ng/filament-tree
More information about back1ng/filament-tree
Files in back1ng/filament-tree
Package filament-tree
Short Description Tree builder for Eloquent models
License MIT
Homepage https://github.com/Back1ng/filament-tree
Informations about the package filament-tree
Eloquent tree with Filament
Build the tree from your Eloquent model with Filament
This plugin offers a tree builder for the Filament admin panel, allows you to build menu, category tree and etc. and management.
Advantages of the plugin:
- Isolation of elements (the tree is not rebuilt when editing, when changing a parent - only the changed nodes are re-rendered).
- “Rememberability” of the collapse state. By default, all nodes are collapsed, as a result, the “children” are not rendered so the page loads quickly.
- Display of any attributes (available here https://filamentphp.com/docs/4.x/infolists/entries/getting-started) of model in the tree, which can be useful for content visualization
- The component is all-sufficient as a resource, there is no need for separate pages for creating, editing, listing models.
- For integration, it is enough to add just a trait (or two, if there was no integration with Nested Set) to the model and specify the name of the attribute that will be used as the node header in the tree.


Table of Contents:
- Installation
- Prepare your model
- Create the tree page
- Configuration
- Customization
- Advanced features
Installation

You can install the package via composer:
Add the plugin service provider to bootstrap/providers.php:
Prepare your model
Trait
A.
You have the existing model with Nested Set integration.
Just add InteractsWithTree trait.
B.
If your model are "clean", so please follow next steps.
-
Add
NodeTraitandInteractsWithTreetraits to the model. - Create new migration
And add columns:
And run the migration:
Tree label attribute
Then please define attribute name of the nodes in your tree, eg. title, add method to the model:
Your model is ready.
Create the tree page
To add the tree page to your admin panel,
call artisan command and input name of page and the model class:
You can setup fields you need while you create or edit any of tree record.
Fill the getCreateForm and getEditForm in your tree page, eg.
Read more about form fields at
https://filamentphp.com/docs/4.x/forms/getting-started



That's all!
Now you can manage your tree based on the model!
Configuration
-
allow-delete-parent
You can restrict to delete nodes having children items. -
allow-delete-root
You can restrict to delete root nodes, even if 'allow-delete-parent' is true. show-parent-select-while-edit
If you want to see edit form as compact one, you able to remove parent's select from it. You still can drag'n'drop the nodes.
You can publish config with:
Customization
Caption
To display any attribute as second line of node label, please add the method to you model and define the caption value:
Infolist
To display any meta information next to node label, you able to fill the method of your page with Infolist entries, eg.
Read more at
https://filamentphp.com/docs/4.x/infolists/entries/getting-started#available-entries
Please note,
created tree page extends Filament Page, so all customizations are available.
Get know about at https://filamentphp.com/docs/4.x/panels/pages
Localization
You can publish translations with:
Optionally, you can publish the views using
Advanced features
Scope
You can have as many models as you want in your project, and you can add a tree page for each one.
But what if your project has multiple menus (for example, in the header and footer) that have the same attributes?
What if the menu items are stored in one table?
You can create a separate page for each of your menus using scopes.
To do this, specify the attribute by which the item belongs to the menu (eg. menu_id), add method to your model:
In you tree page, specify how exactly you need to get the menu items for a specific admin page:
That's all!
Please read more at
https://github.com/lazychaser/laravel-nestedset?tab=readme-ov-file#scoping
Fix tree
If you have changed the structure of your tree, you need to rebuild the relationships of all nodes.
To do this, use the button "Fix tree" at the footer of your tree page.
Support and feedback
If you find a bug, please submit an issue directly to GitHub. Filament Tree Issues
As always, if you need further support, please contact us. https://www.15web.ru/contacts
Copyright and license
Copyright © Studio 15, 2012 - Present.
Code released under the MIT license.
All versions of filament-tree with dependencies
filament/support Version ^4.0
illuminate/contracts Version ^11.28 || ^12.0
kalnoy/nestedset Version ^6.0.5
spatie/laravel-package-tools Version ^1.14.0