antwerpes / filament-nested-set-order
Filament plugin for ordering resources stored using the nested set model
1.1.0
2023-06-05 09:03 UTC
Requires
- php: ^8.1
- filament/filament: ^2.10
- illuminate/contracts: ^9.0|^10.0
- kalnoy/nestedset: ^6.0.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- chiiya/laravel-code-style: ^1.7
- orchestra/testbench: ^6.0|^7.1
This package is auto-updated.
Last update: 2024-11-10 00:03:39 UTC
README
Filament actions for ordering resources that use kalnoy/nestedset.
Installation
composer require antwerpes/filament-nested-set-order
Usage
- Ensure your models use the
Kalnoy\Nestedset\NodeTrait
andAntwerpes\FilamentNestedSetOrder\Orderable
traits.
class Category extends Model { use NodeTrait; use Orderable; }
- Add the actions to your filament resource and specify the query order:
use Antwerpes\FilamentNestedSetOrder\NestedSetOrderActions; class CategoryResource extends Resource { public static function table(Table $table): Table { return $table->prependActions(NestedSetOrderActions::make()); } public static function getEloquentQuery(): Builder { return parent::getEloquentQuery()->withDepth()->defaultOrder(); } }
Caching
To improve performance you may enable caching:
- Publish the config file:
php artisan vendor:publish --tag="filament-nested-set-order-config"
- Enable caching:
return [ 'cache_enabled' => true, ];
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Contributions are welcome! Leave an issue on GitHub, or create a Pull Request.
License
The MIT License (MIT). Please see License File for more information.