A field that adds reordering functionality to your Laravel Nova resource's index using the eloquent-sortable package by Spatie.
This package can be installed through Composer.
composer require michielkempen/nova-order-field
- Follow the usage instructions on the eloquent-sortable repository to make your model sortable.
- Add the
MichielKempen\NovaOrderField\Orderable
trait to your Nova Resource. - Add a public static property called
$defaultSortField
to your resource, containing your order column. - Add the
OrderField
to your Nova Resourcefields
method.
use MichielKempen\NovaOrderField\Orderable;
use MichielKempen\NovaOrderField\OrderField;
class Page extends Resource
{
use Orderable;
public static $defaultOrderField = 'order';
public function fields(Request $request)
{
return [
OrderField::make('Order'),
];
}
}