PHPackages                             workup/nova-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. [Admin Panels](/categories/admin)
4. /
5. workup/nova-sortable

ActiveLibrary[Admin Panels](/categories/admin)

workup/nova-sortable
====================

This Laravel Nova package allows you to reorder models in a Nova resource's index view using drag &amp; drop (forked from optimistdigital/nova-sortable).

3.4.4.001(2y ago)01.5kMITVuePHP &gt;=8.0

Since Nov 1Pushed 2y agoCompare

[ Source](https://github.com/workupsrl/nova-sortable)[ Packagist](https://packagist.org/packages/workup/nova-sortable)[ GitHub Sponsors](https://github.com/outl1ne)[ RSS](/packages/workup-nova-sortable/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)Dependencies (3)Versions (52)Used By (0)

Nova Sortable
=============

[](#nova-sortable)

[![Latest Version on Packagist](https://camo.githubusercontent.com/93540606e997f54af00cd279bcf51fe280921462eeb09e99be440e2e39c2e8ff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f75746c316e652f6e6f76612d736f727461626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/outl1ne/nova-sortable)[![Total Downloads](https://camo.githubusercontent.com/155895a63103e6500fe00ab24d6725b355e10fdfa39f160161f755bdce7e21a0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f75746c316e652f6e6f76612d736f727461626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/outl1ne/nova-sortable)

This [Laravel Nova](https://nova.laravel.com) package allows you to reorder models in a Nova resource's index view using drag &amp; drop.

Uses Spatie's [eloquent-sortable](https://github.com/spatie/eloquent-sortable) under the hood.

Requirements
------------

[](#requirements)

- `php: >=8.0`
- `laravel/nova: ^4.24.0`

Features
--------

[](#features)

- Drag &amp; drop reorder (on either Index view or HasMany view)
- BelongsTo/MorphsTo reorder support w/ pivot tables
- Move to start and end arrows (makes item first/last)
- Everything from [eloquent-sortable](https://github.com/spatie/eloquent-sortable)
- Localization

Screenshots
-----------

[](#screenshots)

[![Sortable](./docs/sortable.gif)](./docs/sortable.gif)

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

[](#installation)

Install the package in a Laravel Nova project via Composer:

```
# Install package
composer require workup/nova-sortable
```

Usage
-----

[](#usage)

### Create migration

[](#create-migration)

Add an order field to the model using Laravel migrations:

```
// Add order column to the model
Schema::table('some_model', function (Blueprint $table) {
  $table->integer('sort_order');
});

// Set default sort order (just copy ID to sort order)
DB::statement('UPDATE some_model SET sort_order = id');
```

### Implement eloquent-sortable

[](#implement-eloquent-sortable)

Implement the Spatie's `eloquent-sortable` interface and apply the trait:

```
use Spatie\EloquentSortable\Sortable;
use Spatie\EloquentSortable\SortableTrait;

class SomeModel extends Eloquent implements Sortable
{
  use SortableTrait;

  public $sortable = [
    'order_column_name' => 'sort_order',
    'sort_when_creating' => true,
  ];

  ...
}
```

When the model does not have a sortable configuration, the default eloquent-sortable configuration will be used.

### Apply HasSortableRows to Nova resource

[](#apply-hassortablerows-to-nova-resource)

Apply `HasSortableRows` trait from this package on the Resource:

```
use Workup\NovaSortable\Traits\HasSortableRows;

class MyResource extends Resource
{
  use HasSortableRows;

  ...
}
```

NB! This overrides the `indexQuery()` method.

### Disallowing sorting on a per-request/resource basis

[](#disallowing-sorting-on-a-per-requestresource-basis)

You can disable sorting on a per-request or per-resource basis by overriding the `canSort()` on the Resource method like so:

```
public static function canSort(NovaRequest $request, $resource)
{
  // Do whatever here, ie:
  // return user()->isAdmin();
  // return $resource->id !== 5;
  return true;
}
```

NB! This requires you to disable caching (see below).

### Disabling caching

[](#disabling-caching)

If you want to disable caching due to using `canSort` or running tests, you can set `sortableCacheEnabled` to false on the resource that has the `HasSortableRows` trait. See the example below:

```
class Artist extends Resource
{
    use HasSortableRows;

    public static $sortableCacheEnabled = false;
}
```

Or if you want to temporarily disable sortability cache (for tests), you can call `Resource::disableSortabilityCache()` on the resource.

Custom sortable options
-----------------------

[](#custom-sortable-options)

### Nova sorting order

[](#nova-sorting-order)

To sort your resource in a different order in Nova, you can set the `nova_order_by` flag to `DESC` (`ASC` by default) in the `$sortable` array.

```
class SomeModel extends Eloquent implements Sortable
{
  use SortableTrait;

  public $sortable = [
    'order_column_name' => 'sort_order',
    'sort_when_creating' => true,
    'nova_order_by' => 'DESC',
  ];

  ...
}
```

### Ignoring policies

[](#ignoring-policies)

If you have a resource that has `authorizedToUpdate` false, but you want the user to still be able to sort it, you can use the `ignore_policies` flag like so:

```
class SomeModel extends Eloquent implements Sortable
{
  use SortableTrait;

  public $sortable = [
    'order_column_name' => 'sort_order',
    'sort_when_creating' => true,
    'ignore_policies' => true,
  ];

  ...
}
```

Sorting on HasMany relationship
-------------------------------

[](#sorting-on-hasmany-relationship)

**NB!** The resource can only be sorted on **either** the Index view **or** the HasMany list view, but not both!

Sorting on HasMany is simple. Add `'sort_on_has_many' => true` to the `$sortable` array on the model. Like so:

```
public $sortable = [
  'order_column_name' => 'sort_order',
  'sort_when_creating' => true,
  'sort_on_has_many' => true,
];
```

The sort on has many configuration can be apply in a per model basis or it can be added in the eloquent-sortable configuration for all the models.

```
return [

    // Spatie sortable configuration

    /**
     * Add sort on has many in all the models.
     **/
    'sort_on_has_many' => true,
];
```

Sorting on ManyToMany relationships
-----------------------------------

[](#sorting-on-manytomany-relationships)

Sorting on BelongsToMany and MorphToMany relationships is available, but requires special steps.

See the documentation here: [Sorting ManyToMany relationships (w/ pivot table)](docs/sorting/many-to-many.md).

Localization
------------

[](#localization)

The translation file(s) can be published by using the following publish command:

```
php artisan vendor:publish --provider="Workup\NovaSortable\ToolServiceProvider" --tag="translations"
```

You can add your translations to `resources/lang/vendor/nova-sortable/` by creating a new translations file with the locale name (ie `et.json`) and copying the JSON from the existing `en.json`.

Other usecases
--------------

[](#other-usecases)

### Using indexQuery

[](#using-indexquery)

This package overwrites the `indexQuery` of the Resource and if you still want to use it, you can do it as follows:

```
use HasSortableRows {
    indexQuery as indexSortableQuery;
}

public static function indexQuery(NovaRequest $request, $query)
{
  // Do whatever with the query
  // ie $query->withCount(['children', 'descendants', 'modules']);
  return parent::indexQuery($request, static::indexSortableQuery($request, $query));
}
```

Credits
-------

[](#credits)

- [Tarvo Reinpalu](https://github.com/Tarpsvo)

License
-------

[](#license)

Nova Sortable is open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 81.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~28 days

Recently: every ~195 days

Total

50

Last Release

997d ago

Major Versions

1.6.2 → 2.0.02020-12-04

2.4.0.001 → 3.4.4.0012023-08-25

PHP version history (4 changes)1.0.0PHP &gt;=7.1.0

2.0.0PHP &gt;=7.3.0

2.4.0.001PHP ^8.0

3.4.4.001PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/f39fbc2fe4ec64f1aa658f8b66206ce0a476d16eac277fb809b19a4c4421fcb5?d=identicon)[workup](/maintainers/workup)

---

Top Contributors

[![Tarpsvo](https://avatars.githubusercontent.com/u/2018660?v=4)](https://github.com/Tarpsvo "Tarpsvo (306 commits)")[![KasparRosin](https://avatars.githubusercontent.com/u/33309407?v=4)](https://github.com/KasparRosin "KasparRosin (19 commits)")[![mertasan](https://avatars.githubusercontent.com/u/13007665?v=4)](https://github.com/mertasan "mertasan (10 commits)")[![pzmarzly](https://avatars.githubusercontent.com/u/8074163?v=4)](https://github.com/pzmarzly "pzmarzly (3 commits)")[![stefblokdijk](https://avatars.githubusercontent.com/u/15145744?v=4)](https://github.com/stefblokdijk "stefblokdijk (3 commits)")[![rubinred](https://avatars.githubusercontent.com/u/13568158?v=4)](https://github.com/rubinred "rubinred (3 commits)")[![LTKort](https://avatars.githubusercontent.com/u/2412670?v=4)](https://github.com/LTKort "LTKort (3 commits)")[![FaridAghili](https://avatars.githubusercontent.com/u/8607021?v=4)](https://github.com/FaridAghili "FaridAghili (2 commits)")[![jonerickson](https://avatars.githubusercontent.com/u/3356740?v=4)](https://github.com/jonerickson "jonerickson (2 commits)")[![lisotton](https://avatars.githubusercontent.com/u/1653860?v=4)](https://github.com/lisotton "lisotton (2 commits)")[![fkraefft](https://avatars.githubusercontent.com/u/25204406?v=4)](https://github.com/fkraefft "fkraefft (2 commits)")[![rslanzi](https://avatars.githubusercontent.com/u/7341598?v=4)](https://github.com/rslanzi "rslanzi (2 commits)")[![shaffe-fr](https://avatars.githubusercontent.com/u/3834222?v=4)](https://github.com/shaffe-fr "shaffe-fr (2 commits)")[![Jnewbon](https://avatars.githubusercontent.com/u/48688400?v=4)](https://github.com/Jnewbon "Jnewbon (2 commits)")[![TheSETJ](https://avatars.githubusercontent.com/u/10893088?v=4)](https://github.com/TheSETJ "TheSETJ (1 commits)")[![Abather](https://avatars.githubusercontent.com/u/18185658?v=4)](https://github.com/Abather "Abather (1 commits)")[![trippo](https://avatars.githubusercontent.com/u/497169?v=4)](https://github.com/trippo "trippo (1 commits)")[![ackermann](https://avatars.githubusercontent.com/u/4266125?v=4)](https://github.com/ackermann "ackermann (1 commits)")[![andre4nap](https://avatars.githubusercontent.com/u/3274022?v=4)](https://github.com/andre4nap "andre4nap (1 commits)")[![angelsk](https://avatars.githubusercontent.com/u/606510?v=4)](https://github.com/angelsk "angelsk (1 commits)")

---

Tags

laravelnovaoptimistdigitaloutl1neeloquent-sortable

### Embed Badge

![Health badge](/badges/workup-nova-sortable/health.svg)

```
[![Health](https://phpackages.com/badges/workup-nova-sortable/health.svg)](https://phpackages.com/packages/workup-nova-sortable)
```

###  Alternatives

[optimistdigital/nova-sortable

This Laravel Nova package allows you to reorder models in a Nova resource's index view using drag &amp; drop.

2872.1M6](/packages/optimistdigital-nova-sortable)[outl1ne/nova-sortable

This Laravel Nova package allows you to reorder models in a Nova resource's index view using drag &amp; drop.

2861.8M9](/packages/outl1ne-nova-sortable)[optimistdigital/nova-settings

A Laravel Nova tool for editing custom settings using native Nova fields.

297874.5k3](/packages/optimistdigital-nova-settings)[outl1ne/nova-translations-loader

This Laravel Nova package helps developers load translations into their packages.

395.1M42](/packages/outl1ne-nova-translations-loader)[optimistdigital/nova-translations-loader

This Laravel Nova package helps developers load translations into their packages.

393.7M10](/packages/optimistdigital-nova-translations-loader)[optimistdigital/nova-page-manager

Page(s) and region(s) manager for Laravel Nova.

17988.5k](/packages/optimistdigital-nova-page-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
