This trick was submitted before the admin panel had reordering functionality. You can find out more about that in the docs.
Install the spatie/eloquent-sortable package .
Create table actions to move the record up and down:
Tables\Actions\Action::make('up') ->action(fn (YourModel $record) => $record->moveOrderUp()),Tables\Actions\Action::make('down') ->action(fn (YourModel $record) => $record->moveOrderDown()),
protected function getTableQuery(): Builder{ return parent::getTableQuery()->orderBy('your_order_column');}
even nicer:
please note the secon icon doe snot show if make is set to empty string
Is there any way to use it with belong_to_many relationship?
I need to set the sort order in my relation table that is used to attach between 2 models.