PHPackages                             almirhodzic/nova-sortable-5 - 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. almirhodzic/nova-sortable-5

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

almirhodzic/nova-sortable-5
===========================

A Laravel Nova 5 package for drag-and-drop sorting of resources with an orderable field.

v1.0.4(2mo ago)027↓100%MITPHPPHP ^8.2

Since Mar 9Pushed 2mo agoCompare

[ Source](https://github.com/almirhodzic/nova-sortable-5)[ Packagist](https://packagist.org/packages/almirhodzic/nova-sortable-5)[ Docs](https://novafront.dev)[ RSS](/packages/almirhodzic-nova-sortable-5/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Nova Sortable 5
===============

[](#nova-sortable-5)

[![Nova Sortable 5](https://camo.githubusercontent.com/781b66c3dc2b316f41bc107814075c7fce91a8efa1ab80c8b2cb841832014e4d/68747470733a2f2f6e6f766166726f6e742e6465762f696d616765732f736f727461626c652f736f727461626c652d73637265656e73686f742e6a7067)](https://camo.githubusercontent.com/781b66c3dc2b316f41bc107814075c7fce91a8efa1ab80c8b2cb841832014e4d/68747470733a2f2f6e6f766166726f6e742e6465762f696d616765732f736f727461626c652f736f727461626c652d73637265656e73686f742e6a7067)

A Laravel Nova 5 package for drag-and-drop and arrow-based sorting of resources.

- Drag-and-drop reordering via [SortableJS](https://sortablejs.github.io/Sortable/)
- Up/down arrow buttons for precise ordering
- Visual feedback: green border on moved row, red border on displaced row
- Toast notifications on success/error
- Publishable config for global defaults
- No full page reload — instant DOM updates

Table of Contents
-----------------

[](#table-of-contents)

- [Requirements](#requirements)
- [Installation](#installation)
- [Setup](#setup)
    - [1. Add a sort column to your table](#1-add-a-sort-column-to-your-table)
    - [2. Add the trait to your Eloquent Model](#2-add-the-trait-to-your-eloquent-model)
    - [3. Add the trait and field to your Nova Resource](#3-add-the-trait-and-field-to-your-nova-resource)
- [Configuration](#configuration)
- [Field Options](#field-options)
- [How it works](#how-it-works)
- [Model Features](#model-features)
- [License](#license)

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

[](#requirements)

- PHP ^8.2
- Laravel Nova ^5.0

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

[](#installation)

```
composer require almirhodzic/nova-sortable-5
```

The service provider is auto-discovered. No manual registration needed.

### Publish the config (optional)

[](#publish-the-config-optional)

```
php artisan vendor:publish --tag=frontbyte-nova-sortable-config
```

This creates `config/frontbyte-nova-sortable.php` where you can set global defaults.

Setup
-----

[](#setup)

### 1. Add a sort column to your table

[](#1-add-a-sort-column-to-your-table)

**New table:**

```
Schema::create('services', function (Blueprint $table) {
    $table->id();
    $table->unsignedInteger('sort_order')->default(0);
    // ... other columns
    $table->timestamps();
});
```

**Existing table** — create a migration to add the column:

```
php artisan make:migration add_sort_order_to_services_table
```

```
Schema::table('services', function (Blueprint $table) {
    $table->unsignedInteger('sort_order')->default(0)->after('id');
});
```

Then run the migration:

```
php artisan migrate
```

After migrating, you can initialize the order values for existing rows:

```
php artisan tinker
```

```
App\Models\Service::query()->each(function ($service, $index) {
    $service->update(['sort_order' => $index + 1]);
});
```

### 2. Add the trait to your Eloquent Model

[](#2-add-the-trait-to-your-eloquent-model)

```
use AlmirHodzic\NovaSortable5\HasSortableRows;

class Service extends Model
{
    use HasSortableRows;

    protected string $sortableColumn = 'sort_order';
}
```

The `$sortableColumn` property is optional. If omitted, it uses the `default_column` from the config (default: `order`).

### 3. Add the trait and field to your Nova Resource

[](#3-add-the-trait-and-field-to-your-nova-resource)

```
use AlmirHodzic\NovaSortable5\Sortable;
use AlmirHodzic\NovaSortable5\SortableResource;

class Service extends Resource
{
    use SortableResource;

    public function fields(NovaRequest $request): array
    {
        return [
            Sortable::make('Order', 'sort_order'),

            // ... other fields
        ];
    }
}
```

The `SortableResource` trait ensures Nova sorts by your sortable column by default, preventing conflicts with drag-and-drop.

> **Tip:** If you're adding this package to an existing resource with pre-existing rows, their `sort_order` values will initially all be `0`. Simply perform a single drag-and-drop reorder in the admin panel — the package will automatically recalculate and persist the `sort_order` for all rows in the table.

Configuration
-------------

[](#configuration)

After publishing, edit `config/frontbyte-nova-sortable.php`:

```
return [
    // Default database column for sorting
    'default_column' => 'sort_order',

    // Default sort direction: 'asc' or 'desc'
    'order_direction' => 'asc',

    // Show the drag handle (bars icon)
    'show_drag_handle' => true,

    // Show up/down arrow buttons
    'show_order_arrows' => true,

    // Show the order number
    'show_order_number' => true,

    // Show toast messages after reordering
    'show_toast' => true,

    // Authentication guards for the API routes
    'guards' => ['web'],
];
```

All config values serve as global defaults. You can override them per field (see below).

Field Options
-------------

[](#field-options)

You can override config defaults per resource by chaining methods on the `Sortable` field:

MethodDescription`showDragHandle()` / `hideDragHandle()`Toggle drag handle visibility`showSortArrows()` / `hideSortArrows()`Toggle arrow buttons`showOrderNumber()` / `hideOrderNumber()`Toggle order number display`showToast()` / `hideToast()`Toggle success/error toast messages### Auto-assign order on create

[](#auto-assign-order-on-create)

By default, the package automatically assigns the next order value (`max + 1`) when creating a new model. This means every new entry is added to the end of the list.

If you want to control the order value manually (e.g. via a form field), you can disable this:

```
Sortable::make('Order', 'sort_order')
    ->autoAssignOnCreate(false)
```

With auto-assign disabled, you are responsible for setting the `sort_order` value yourself:

```
Service::create([
    'name' => 'My Service',
    'sort_order' => 5, // must be set manually
]);
```

How it works
------------

[](#how-it-works)

**Drag-and-drop:** Grab the bars icon and drag a row to its new position. All affected rows are reordered in a single API call.

**Arrow buttons:** Click the up/down arrows to swap a row with its neighbor. Only the two affected rows are swapped.

**Visual feedback:** After sorting, the moved row flashes green and the displaced row flashes red — providing clear visual confirmation of what changed.

**No page reload:** All updates happen via API calls with instant DOM manipulation. The order numbers update automatically.

Model Features
--------------

[](#model-features)

The `HasSortableRows` trait provides:

```
// Auto-assigns the next order value when creating a model
$service = Service::create(['name' => 'New Service']);
// sort_order is automatically set to max + 1

// Move a model to a specific position (re-indexes other rows)
$service->moveToPosition(1);

// Query scope for custom ordering
Service::orderBySortable('desc')->get();

// Get the sortable column name
$service->getSortableColumn(); // 'sort_order'
```

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

###  Health Score

41

—

FairBetter than 88% of packages

Maintenance94

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

61d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4187300caf44b8a86ff47629482386398a2dbba369117ccf3ba63cfca2342b10?d=identicon)[almirhodzic](/maintainers/almirhodzic)

---

Top Contributors

[![almirhodzic](https://avatars.githubusercontent.com/u/24458972?v=4)](https://github.com/almirhodzic "almirhodzic (12 commits)")

---

Tags

laravellaravel-packagenova-extensionnova-toolnova5sortabletailwindcss-v4typescriptvue3laravelsortablefielddrag-and-dropnovaorderreorder

### Embed Badge

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

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

###  Alternatives

[timothyasp/nova-color-field

A Laravel Nova Color Picker field.

781.6M5](/packages/timothyasp-nova-color-field)[alexwenzel/nova-dependency-container

A Laravel Nova 4 form container for grouping fields that depend on other field values.

461.0M2](/packages/alexwenzel-nova-dependency-container)[simplesquid/nova-enum-field

A Laravel Nova field to add enums to resources.

52391.9k2](/packages/simplesquid-nova-enum-field)[outhebox/nova-hidden-field

A Laravel Nova Hidden field.

33562.2k1](/packages/outhebox-nova-hidden-field)[sietse85/nova-button

(Nova 4+) A Laravel Nova package for adding buttons to your resources.

37347.3k](/packages/sietse85-nova-button)[nikaia/nova-rating-field

Add start rating field to Laravel Nova

42258.6k](/packages/nikaia-nova-rating-field)

PHPackages © 2026

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