PHPackages                             novius/laravel-nova-order-nestedset-field - 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. novius/laravel-nova-order-nestedset-field

ActiveLibrary

novius/laravel-nova-order-nestedset-field
=========================================

A Laravel Nova field that make your resources orderable

5.1.0(1y ago)2490.0k—6.9%12[2 PRs](https://github.com/novius/laravel-nova-order-nestedset-field/pulls)1AGPL-3.0-or-laterPHPPHP ^8.2CI passing

Since Jul 25Pushed 1y ago6 watchersCompare

[ Source](https://github.com/novius/laravel-nova-order-nestedset-field)[ Packagist](https://packagist.org/packages/novius/laravel-nova-order-nestedset-field)[ RSS](/packages/novius-laravel-nova-order-nestedset-field/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (19)Used By (1)

Nova Order Field nestedset
==========================

[](#nova-order-field-nestedset)

[![Travis](https://camo.githubusercontent.com/b7d2ce5ff9276b3dde0fd071e1d884d52c4bb0d18558381a7c3312044bb30620/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6e6f766975732f6c61726176656c2d6e6f76612d6f726465722d6e65737465647365742d6669656c642e7376673f6d61784167653d31383030267374796c653d666c61742d737175617265)](https://travis-ci.org/novius/laravel-nova-order-nestedset-field)[![Packagist Release](https://camo.githubusercontent.com/faed656cfd735f83a9f63ccf2d342dd89a032e819d83fda8a03eb1f57c16d5bc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6f766975732f6c61726176656c2d6e6f76612d6f726465722d6e65737465647365742d6669656c642e7376673f6d61784167653d31383030267374796c653d666c61742d737175617265)](https://packagist.org/packages/novius/laravel-nova-order-nestedset-field)[![Licence](https://camo.githubusercontent.com/c133604cd80f0503815a6a1c39c3abe278871a3017e812b96691c5482e16417e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e6f766975732f6c61726176656c2d6e6f76612d6f726465722d6e65737465647365742d6669656c642e7376673f6d61784167653d31383030267374796c653d666c61742d737175617265)](https://github.com/novius/laravel-nova-order-nestedset-field#licence)

A field that make your resources orderable using [the laravel nestedset package](https://github.com/lazychaser/laravel-nestedset).

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

[](#requirements)

- PHP &gt;= 8.1
- Laravel Nova &gt;= 4.0

> **NOTE**: These instructions are for Laravel Nova 4.0. If you are using prior version, please see the [previous version's docs](https://github.com/novius/laravel-nova-order-nestedset-field/tree/3.x).

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

[](#installation)

```
composer require novius/laravel-nova-order-nestedset-field
```

### Configuration

[](#configuration)

Some options that you can override are available.

```
php artisan vendor:publish --provider="Novius\LaravelNovaOrderNestedsetField\OrderNestedsetFieldServiceProvider" --tag="config"
```

Usage
-----

[](#usage)

**Step 1**

Use Kalnoy\\Nestedset `NodeTrait` and Novius\\LaravelNovaOrderNestedsetField `Orderable` trait on your model.

Example :

```
use Kalnoy\Nestedset\NodeTrait;
use Novius\LaravelNovaOrderNestedsetField\Traits\Orderable;

class Foo extends Model {
    use NodeTrait;
    use Orderable;

    public function getLftName()
    {
        return 'left';
    }

    public function getRgtName()
    {
        return 'right';
    }

    public function getParentIdName()
    {
        return 'parent';
    }
}
```

**Step 2**

Add the field to your resource and specify order for your resources.

```
use Novius\LaravelNovaOrderNestedsetField\OrderNestedsetField;

class FooResource extends Resource
{
    public function fields(Request $request)
    {
        return [
            OrderNestedsetField::make('Order'),
        ];
    }

    /**
     * @param \Illuminate\Database\Eloquent\Builder $query
     * @param array $orderings
     * @return \Illuminate\Database\Eloquent\Builder
     */
    protected static function applyOrderings($query, array $orderings)
    {
        return $query->orderBy('left', 'asc');
    }
}
```

**Scoping**

Imagine you have `Menu` model and `MenuItems`. There is a one-to-many relationship set up between these models. `MenuItem` has `menu_id` attribute for joining models together. `MenuItem` incorporates nested sets. It is obvious that you would want to process each tree separately based on `menu_id` attribute. In order to do so, you need to specify this attribute as scope attribute:

```
    protected function getScopeAttributes()
    {
        return ['menu_id'];
    }
```

[Retrieve more information about usage on official doc](https://github.com/lazychaser/laravel-nestedset#scoping).

Performances
------------

[](#performances)

You can enable cache to avoid performance issues in case of large tree.

**By default cache is disabled.**

To use cache you have to enabled it in config file with :

```
return [
    ...

    'cache_enabled' => true,
];
```

**You have to clear cache on every tree updates with an observer on your Model (or directly in boot method).**

```
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Kalnoy\Nestedset\NodeTrait;
use Novius\LaravelNovaOrderNestedsetField\Traits\Orderable;

class Foo extends Model
{
    use NodeTrait;
    use Orderable;

    public static function boot()
    {
        parent::boot();

        if (config('nova-order-nestedset-field.cache_enabled', false)) {
            static::created(function (Theme $model) {
                $model->clearOrderableCache();
            });

            static::updated(function (Theme $model) {
                $model->clearOrderableCache();
            });

            static::deleted(function (Theme $model) {
                $model->clearOrderableCache();
            });
        }
    }
}
```

Override default languages files
--------------------------------

[](#override-default-languages-files)

Run:

```
php artisan vendor:publish --provider="Novius\LaravelNovaOrderNestedsetField\OrderNestedsetFieldServiceProvider" --tag="lang"
```

Lint
----

[](#lint)

Run php-cs with:

```
composer run-script lint
```

Contributing
------------

[](#contributing)

Contributions are welcome! Leave an issue on Github, or create a Pull Request.

Licence
-------

[](#licence)

This package is under [GNU Affero General Public License v3](http://www.gnu.org/licenses/agpl-3.0.html) or (at your option) any later version.

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance45

Moderate activity, may be stable

Popularity42

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~128 days

Recently: every ~12 days

Total

17

Last Release

431d ago

Major Versions

v0.3-alpha → v1.0.02020-03-16

v1.0.2 → v2.0.02021-07-09

2.x-dev → v3.0.02022-04-19

v3.0.0 → v4.0.02022-04-26

4.x-dev → 5.0.02025-01-24

PHP version history (4 changes)v0.1-alphaPHP &gt;=7.1.0

v2.0.0PHP &gt;=7.4

v3.0.0PHP &gt;=8.1

5.0.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/341860?v=4)[Novius](/maintainers/novius)[@novius](https://github.com/novius)

---

Top Contributors

[![tony-novius](https://avatars.githubusercontent.com/u/243603340?v=4)](https://github.com/tony-novius "tony-novius (9 commits)")[![felixgilles](https://avatars.githubusercontent.com/u/900854?v=4)](https://github.com/felixgilles "felixgilles (7 commits)")[![gerasimovs](https://avatars.githubusercontent.com/u/20923969?v=4)](https://github.com/gerasimovs "gerasimovs (1 commits)")[![karamelichkin](https://avatars.githubusercontent.com/u/6915212?v=4)](https://github.com/karamelichkin "karamelichkin (1 commits)")[![rbnhtl](https://avatars.githubusercontent.com/u/45656057?v=4)](https://github.com/rbnhtl "rbnhtl (1 commits)")[![Ange7](https://avatars.githubusercontent.com/u/4114703?v=4)](https://github.com/Ange7 "Ange7 (1 commits)")[![tonyyb](https://avatars.githubusercontent.com/u/11064382?v=4)](https://github.com/tonyyb "tonyyb (1 commits)")[![FaridAghili](https://avatars.githubusercontent.com/u/8607021?v=4)](https://github.com/FaridAghili "FaridAghili (1 commits)")

---

Tags

laravellaravel-novanovatreelaravelnestedsetnovatreeshierarchies

###  Code Quality

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/novius-laravel-nova-order-nestedset-field/health.svg)

```
[![Health](https://phpackages.com/badges/novius-laravel-nova-order-nestedset-field/health.svg)](https://phpackages.com/packages/novius-laravel-nova-order-nestedset-field)
```

###  Alternatives

[dillingham/nova-attach-many

Attach Many Nova field

2712.0M2](/packages/dillingham-nova-attach-many)[sbine/route-viewer

A Laravel Nova tool to view your registered routes.

57215.9k](/packages/sbine-route-viewer)[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

14720.0k](/packages/markwalet-nova-modal-response)[stepanenko3/nova-cards

A Laravel Nova info cards.

33143.0k](/packages/stepanenko3-nova-cards)[pos-lifestyle/laravel-nova-date-range-filter

A Laravel Nova date range filter.

16179.1k](/packages/pos-lifestyle-laravel-nova-date-range-filter)

PHPackages © 2026

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