PHPackages                             christophe-44-27/nova-field-sortable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. christophe-44-27/nova-field-sortable

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

christophe-44-27/nova-field-sortable
====================================

A Laravel Nova field to easily sort records in your tables.

00PHP

Since Jun 5Pushed 1y agoCompare

[ Source](https://github.com/christophe-44-27/nova-field-sortable)[ Packagist](https://packagist.org/packages/christophe-44-27/nova-field-sortable)[ RSS](/packages/christophe-44-27-nova-field-sortable/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Nova Sortable Field
===========================

[](#laravel-nova-sortable-field)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7fbaa5e6c3a326c6eaba50c8800dbce4590e4fac81b008acc11adcb412fb6364/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6368726973746f7068652d34342d32372f6e6f76612d6669656c642d736f727461626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/christophe-44-27/nova-field-sortable)[![Total Downloads](https://camo.githubusercontent.com/ff79d336f0a6dd05370b451f9238816d9702ec1b81c807c67304c0f00eb50f1a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6368726973746f7068652d34342d32372f6e6f76612d6669656c642d736f727461626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/christophe-44-27/nova-field-sortable)

Description
-----------

[](#description)

This field adds reordering functionality to your resource's index using the awesome [eloquent-sortable](https://github.com/spatie/eloquent-sortable) package by the great people of [Spatie](https://spatie.be).

[![screenshot](https://github.com/christophe-44-27/nova-field-sortable/raw/master/docs/screenshot.png)](https://github.com/christophe-44-27/nova-field-sortable/raw/master/docs/screenshot.png)

Requrements
-----------

[](#requrements)

- Laravel 12+ with Nova.
- [spatie/eloquent-sortable](https://github.com/spatie/eloquent-sortable) (If not already installed, this package will install if for you and all you have to do is follow the [installation](https://github.com/spatie/eloquent-sortable#installation) instructions).

Installation
------------

[](#installation)

This package can be installed through Composer.

```
composer require christophe-44-27/nova-field-sortable
```

Usage
-----

[](#usage)

1. Follow the [usage instructions](https://github.com/spatie/eloquent-sortable#usage) on the eloquent-sortable repository to make your model sortable.
2. Use the `CodeWithChristophe\NovaFieldSortable\Concerns\SortsIndexEntries` trait in your Nova Resource.
3. Add a public static property called `$defaultSortField` to your resource, containing your sorting column (I recomment adding it in your main `app/Nova/Resource.php` file).
4. Add the `CodeWithChristophe\NovaFieldSortable\Sortable` field to your Nova Resource `fields` method, using a label and your primary key column.

### Example

[](#example)

```
