antwerpes/filament-nested-set-order
Filament Nested Set Order
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\NodeTraitandAntwerpes\FilamentNestedSetOrder\Orderabletraits.
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.