PHPackages                             webfactorybulgaria/nestablecollection - 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. [Database &amp; ORM](/categories/database)
4. /
5. webfactorybulgaria/nestablecollection

ActiveLibrary[Database &amp; ORM](/categories/database)

webfactorybulgaria/nestablecollection
=====================================

A Laravel Package that extends Collection to handle unlimited nested items following adjacency list model.

v4.0.0(10y ago)05091MITPHP

Since Feb 18Pushed 10y ago1 watchersCompare

[ Source](https://github.com/webfactorybulgaria/NestableCollection)[ Packagist](https://packagist.org/packages/webfactorybulgaria/nestablecollection)[ RSS](/packages/webfactorybulgaria-nestablecollection/feed)WikiDiscussions master Synced 4w ago

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

NestableCollection
==================

[](#nestablecollection)

[![SensioLabsInsight](https://camo.githubusercontent.com/b5778b3fe39d52eebd3149066c11b3f438930a283076ced08ea978decf579f74/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f38646333343962342d393531642d343039382d616633612d6332393131393337613930312f6d696e692e706e67)](https://insight.sensiolabs.com/projects/8dc349b4-951d-4098-af3a-c2911937a901)

A Laravel/Lumen Package that extends Collection to handle unlimited nested items following adjacency list model.

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

[](#installation)

Run `composer require typicms/nestablecollection`

Usage
-----

[](#usage)

The model must have a **parent\_id** attributes :

```
protected $fillable = array(
    'parent_id',
    // …
}
```

and must use the following trait:

```
use TypiCMS\NestableTrait;
```

Now each time you get a collection of that model, it will be an instance of **TypiCMS\\NestableCollection** in place of **Illuminate\\Database\\Eloquent\\Collection**.

If you want a tree of models, simply call the nest method on a collection ordered by parent\_id asc :

```
Model::orderBy('parent_id')->get()->nest();
```

Of course you will probably want a position column as well. So you will have to order first by parent\_id asc and then by position asc.

Indented and flattened list
---------------------------

[](#indented-and-flattened-list)

`listsFlattened()` method generate the tree as a flattened list with id as keys and title as values, perfect for select/option, for example :

```
[
    '22' => 'Item 1 Title',
    '10' => '    Child 1 Title',
    '17' => '    Child 2 Title',
    '14' => 'Item 2 Title',
]
```

To use it, first call the `nest()` method, followed by the `listsFlattened()` method:

```
Model::orderBy('parent_id')->get()->nest()->listsFlattened();
```

By default it will look for a `title` column. You send as first parameter a custom column name:

```
Model::orderBy('parent_id')->get()->nest()->listsFlattened('name');
```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 87.9% 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 ~58 days

Recently: every ~70 days

Total

6

Last Release

3854d ago

Major Versions

v1.1.1 → v4.0.02015-12-11

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1948577?v=4)[Webfactory](/maintainers/webfactorybulgaria)[@webfactorybulgaria](https://github.com/webfactorybulgaria)

---

Top Contributors

[![sdebacker](https://avatars.githubusercontent.com/u/134503?v=4)](https://github.com/sdebacker "sdebacker (29 commits)")[![nWidart](https://avatars.githubusercontent.com/u/882397?v=4)](https://github.com/nWidart "nWidart (4 commits)")

---

Tags

laraveleloquentcollectiontreeadjacency listnested-setTypiCMS

### Embed Badge

![Health badge](/badges/webfactorybulgaria-nestablecollection/health.svg)

```
[![Health](https://phpackages.com/badges/webfactorybulgaria-nestablecollection/health.svg)](https://phpackages.com/packages/webfactorybulgaria-nestablecollection)
```

###  Alternatives

[typicms/nestablecollection

A Laravel Package that extends Collection to handle unlimited nested items following adjacency list model.

88334.0k24](/packages/typicms-nestablecollection)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k29.9M42](/packages/kirschbaum-development-eloquent-power-joins)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[watson/validating

Eloquent model validating trait.

9733.4M53](/packages/watson-validating)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8723.1M23](/packages/yajra-laravel-oci8)[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k322.4k1](/packages/cybercog-laravel-love)

PHPackages © 2026

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