Sorting Table with spatie/eloquent-sortable

Sep 16, 2022
Lloric Mayuga Garcia
Table builder, Integration

When using spatie/eloquent-sortable, you have a extensive sorting function to your eloquent.

In your resource component add this to your table():

public static function table(Table $table): Table
return $table
Tables\Columns\TextColumn::make('order_column', '#')
// ...
// ...

Add this to your ListRecords page:

public function reorderTable(array $order): void

And that's it!, you have have a working sortable eloquent by Spatie.

No comments yet…