Skip to content

Latest commit

 

History

History
72 lines (51 loc) · 2.03 KB

README.md

File metadata and controls

72 lines (51 loc) · 2.03 KB

Filament Nested Set Order

Latest Version on Packagist GitHub Code Style Action Status Total Downloads

Filament actions for ordering resources that use kalnoy/nestedset.

Installation

composer require antwerpes/filament-nested-set-order

Usage

  1. Ensure your models use the Kalnoy\Nestedset\NodeTrait and Antwerpes\FilamentNestedSetOrder\Orderable traits.
class Category extends Model
{
    use NodeTrait;
    use Orderable;
}
  1. 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:

  1. Publish the config file:
php artisan vendor:publish --tag="filament-nested-set-order-config"
  1. 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.