Filament actions for ordering resources that use kalnoy/nestedset.
composer require antwerpes/filament-nested-set-order
- 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();
}
}
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,
];
Please see CHANGELOG for more information on what has changed recently.
Contributions are welcome! Leave an issue on GitHub, or create a Pull Request.
The MIT License (MIT). Please see License File for more information.