invaders-xx/filament-nested-list
Composer 安装命令:
composer require invaders-xx/filament-nested-list
包简介
Nested lists layout plugin for Filament
README 文档
README
Filament Nested List
Filament Nested List is a plugin for Filament Admin that creates a model management page with a heritage nested list structure view. This plugin can be used to create menus and more.
This plugin creates model management page with heritage nested list structure view for Filament Admin. It could be used to create menu, etc.
Installation
To install the package, run the following command:
composer require invaders-xx/filament-nested-list
php artisan filament:assets
Note: Add plugin Blade files to your custom theme
tailwind.config.jsfor dark mode.To set up your own custom theme, you can visit the official instruction page on the Filament website.
Add the plugin's views to your tailwind.config.js file.
content: [ '<path-to-vendor>/invaders-xx/filament-nested-list/resources/**/*.blade.php', ]
Then, publish the config file using:
php artisan vendor:publish --tag="filament-nested-list-config"
You can set your preferred options by adding the following code to your config/filament-nested-list.php file:
<?php return [ /** * Tree model fields */ 'column_name' => [ 'order' => 'order', 'parent' => 'parent_id', 'title' => 'title', ], /** * Tree model default parent key */ 'default_parent_id' => -1, /** * Tree model default children key name */ 'default_children_key_name' => 'children', ];
Usage
Prepare the database and model
To use Filament Nested List, follow these table structure conventions:
Tip: The
parent_idfield must always default to -1!!!
Schema::create('product_categories', function (Blueprint $table) {
$table->id();
$table->integer('parent_id')->default(-1);
$table->integer('order')->default(0)->index();
$table->string('title');
$table->timestamps();
});
This plugin provides a convenient method called nestedListColumns() that you can use to add the required columns for
the nested list structure to your table more easily. Here's an example:
Schema::create('product_categories', function (Blueprint $table) {
$table->id();
$table->nestedListColumns();
$table->timestamps();
});
This will automatically add the required columns for the nested list structure to your table.
The above table structure contains three required fields: parent_id, order, title, and other fields do not have
any requirements.
The corresponding model is app/Models/ProductCategory.php:
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use InvadersXX\FilamentNestedList\Concern\ModelNestedList; class ProductCategory extends Model { use ModelNestedList; protected $fillable = ["parent_id", "title", "order"]; protected $table = 'product_categories'; }
The field names of the three fields parent_id, order, and title in the table structure can also be modified:
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use InvadersXX\FilamentNestedList\Concern\ModelNestedList; class ProductCategory extends Model { use ModelNestedList; protected $fillable = ["parent_id", "title", "order"]; protected $table = 'product_categories'; // Default if you need to override // public function determineOrderColumnName(): string // { // return "order"; // } // public function determineParentColumnName(): string // { // return "parent_id"; // } // public function determineTitleColumnName(): string // { // return 'title'; // } // public static function defaultParentKey() // { // return -1; // } // public static function defaultChildrenKeyName(): string // { // return "children"; // } }
Widget
Filament provides a powerful feature that allows you to display widgets inside pages, below the header and above the footer. This can be useful for adding additional functionality to your resource pages.
To create a Nested List Widget and apply it to a resource page, you can follow these steps:
1. Creating a Filament Resource Page
To create a resources page, run the following command:
php artisan make:filament-resource ProductCategory
2. Create Nested List Widget
Prepare the filament-nested-list Widget and show it in Resource page.
php artisan make:filament-nested-list-widget ProductCategoryWidget
Now you can see the Widget in Filament Folder
<?php namespace App\Filament\Widgets; use App\Models\ProductCategory as ModelsProductCategory; use App\Filament\Widgets; use Filament\Forms\Components\TextInput; use InvadersXX\FilamentNestedList\Widgets\NestedList as BaseWidget; class ProductCategoryWidget extends BaseWidget { protected static string $model = ModelsProductCategory::class; // you can customize the maximum depth of your tree protected static int $maxDepth = 2; protected ?string $itle = 'ProductCategory'; protected bool $enableTitle = true; protected function getFormSchema(): array { return [ TextInput::make('title'), ]; } }
3. Displaying a widget on a resource page
Once you have created the widget, modify the getHeaderWidgets() or getFooterWidgets() methods of the resource page
to show the nested list view:
<?php namespace App\Filament\Resources\ProductCategoryResource\Pages; use App\Filament\Resources\ProductCategoryResource; use App\Filament\Widgets\ProductCategory; use Filament\Pages\Actions; use Filament\Resources\Pages\ListRecords; class ListProductCategories extends ListRecords { protected static string $resource = ProductCategoryResource::class; protected function getActions(): array { return [ Actions\CreateAction::make(), ]; } protected function getHeaderWidgets(): array { return [ ProductCategory::class ]; } }
Publishing Views
To publish the views, use:
php artisan vendor:publish --tag="filament-nested-list-views"
Publishing Translations
To publish the translations, use:
php artisan vendor:publish --tag="filament-nested-list-translations"
Testing
To run the tests, run:
composer test
Changelog
See the CHANGELOG for more information on what has changed recently.
Contributing
See CONTRIBUTING for details.
Security Vulnerabilities
If you discover any security related issues, please email info+package@solutionforest.net instead of using the issue tracker.
Credits
- David Vincent
- Inspired from Solution Forest
- hesamurai for nested sort script
- All Contributors
License
Filament Nested List is open-sourced software licensed under the MIT license.
About Us
invaders-xx/filament-nested-list 适用场景与选型建议
invaders-xx/filament-nested-list 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.84k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2024 年 04 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「Envahisseur」 「filament-nested-list」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 invaders-xx/filament-nested-list 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 invaders-xx/filament-nested-list 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 invaders-xx/filament-nested-list 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
Laravel package for Accurate Online API integration.
Shared RCX Laravel DataTables UI and configuration helpers.
Boot a Laravel project on any machine with one command: app:serve installs missing tools (PHP, Node, Composer, Herd, Docker), creates .env, sets up the database, runs migrations, builds assets, starts a queue worker and serves via Herd, Sail or artisan serve; app:down cleanly stops everything it sta
Branded, diagnostic error pages (500, 403, 404, 419, 503) for Filament — native Filament UI, dark mode and translations out of the box.
Turn any PDF into a Pingen-ready A4 letter (generated address cover page + A4 normalisation + safe margins) and send it through the Pingen print & mail API. Laravel-first.
统计信息
- 总下载量: 4.84k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-04-23