maize-tech/laravel-nova-eloquent-sortable
A Laravel Nova integration for eloquent-sortable models that adds drag-and-drop reordering and sortable controls to Nova resources, making it easy to manage model order in the admin panel without custom code.
Install the package via Composer and publish any required configuration or migrations:
composer require <vendor>/<package>
php artisan vendor:publish --provider="<Vendor>\<Package>\<PackageServiceProvider>"
php artisan migrate
The first place to look is the OrderColumn class (and any accompanying trait or interface). Its public methods define the supported reordering operations—typically moveToStart, moveToEnd, moveBefore, moveAfter, and methods for bulk reordering. Check the package README and the OrderColumn tests for concrete examples of the API.
A minimal first use case is a model with an integer order column. Add the provided trait (or use the OrderColumn class directly) to the model, then reorder a record:
$item = Item::find(1);
$item->moveToStart(); // or moveBefore($otherItem), etc.
Ensure the model’s table has the expected order column and that the column is included in $fillable only if you need mass assignment.
HasOrder or similar) and declare the order column name if it differs from the default (order). If the package does not provide a trait, use the OrderColumn class as a service to reorder models.lockForUpdate() to prevent race conditions.CASE WHEN update. Always wrap in a transaction.move* methods. Most packages provide a controller or endpoint that accepts a JSON array of IDs.lockForUpdate) and consider optimistic locking (a version column) if supported.OrderColumn class. Always run the latest patch; if you were on 3.0.0, review the diff for any behavioral changes affecting your reordering logic.whereNull('deleted_at').php artisan config:clear).DB::listen() or Laravel Telescope to inspect the SQL generated during reordering. Look for unexpected UPDATE statements or missing WHERE clauses that could reorder unintended rows.OrderColumn class or override trait methods in your model to customise behaviour (e.g., custom order value assignment). Check the package’s contracts and interfaces for safe extension points.How can I help you explore Laravel packages today?