PHPackages                             efureev/laravel-trees - 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. efureev/laravel-trees

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

efureev/laravel-trees
=====================

Multi-Tree structures for Laravel

v5.6.0(1mo ago)14253.3k—8.3%20[2 issues](https://github.com/efureev/laravel-trees/issues)3MITPHPPHP ^8.2CI passing

Since Feb 8Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/efureev/laravel-trees)[ Packagist](https://packagist.org/packages/efureev/laravel-trees)[ RSS](/packages/efureev-laravel-trees/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (20)Versions (98)Used By (3)

Laravel Tree Structure
======================

[](#laravel-tree-structure)

[![PHP Laravel Package](https://github.com/efureev/laravel-trees/workflows/PHP%20Laravel%20Package/badge.svg?branch=master)](https://github.com/efureev/laravel-trees/workflows/PHP%20Laravel%20Package/badge.svg?branch=master)[![PHP Version](https://camo.githubusercontent.com/8fea469e49436828d18e210fb695b74b284f6d164c00475ba62d37ab0ec7efd6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e32253743382e33253743382e34253743382e352d626c75652e737667)](https://camo.githubusercontent.com/8fea469e49436828d18e210fb695b74b284f6d164c00475ba62d37ab0ec7efd6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e32253743382e33253743382e34253743382e352d626c75652e737667)[![Laravel Version](https://camo.githubusercontent.com/edea1f5f0e1f39c9168ce83d6f1d71ae27e93c857015c7f97f54629c808a07dd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d313125374331322e2a2d7265642e737667)](https://camo.githubusercontent.com/edea1f5f0e1f39c9168ce83d6f1d71ae27e93c857015c7f97f54629c808a07dd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d313125374331322e2a2d7265642e737667)[![Total Downloads](https://camo.githubusercontent.com/b28b4247ce78b0a83e04eb81f645cdc28ccd3fa2139d421046fa2a7e53145ad2/68747470733a2f2f706f7365722e707567782e6f72672f656675726565762f6c61726176656c2d74726565732f646f776e6c6f616473)](https://packagist.org/packages/efureev/laravel-trees)[![License](https://camo.githubusercontent.com/168c7161009eef1cace44070f0f16f331ae2e965a795bfbd5e39ff5c414d554b/68747470733a2f2f706f7365722e707567782e6f72672f656675726565762f6c61726176656c2d74726565732f6c6963656e7365)](https://packagist.org/packages/efureev/laravel-trees)[![composer.lock available](https://camo.githubusercontent.com/455feb0191da47195d175cc5c9fa9dad8ba237cc92718fca5dd51f63822db231/68747470733a2f2f706f7365722e707567782e6f72672f656675726565762f6c61726176656c2d74726565732f636f6d706f7365726c6f636b)](https://packagist.org/packages/efureev/laravel-trees)[![Latest Stable Version](https://camo.githubusercontent.com/dbb9cafcd80f37ca1075f180906bc94ff8717f1e104dd41e5d718d2b2721426d/68747470733a2f2f706f7365722e707567782e6f72672f656675726565762f6c61726176656c2d74726565732f76657273696f6e)](https://packagist.org/packages/efureev/laravel-trees)[![Maintainability](https://camo.githubusercontent.com/dd1efccc696f13bc0b6228e7ec9e93c4979147835c1fca9a64723e6deb8a418a/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f36396566663030393861646266373238333431642f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/efureev/laravel-trees/maintainability)[![Test Coverage](https://camo.githubusercontent.com/715b40bc40cc31a833ce26bbe849410c8b3df19159c9e5864fb9d3d4aeee39d7/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f36396566663030393861646266373238333431642f746573745f636f766572616765)](https://codeclimate.com/github/efureev/laravel-trees/test_coverage)[![PHPStan Level](https://camo.githubusercontent.com/9c993481c3bca6625658657a2812cdd8bec2daf7aae7cd224d244dfb77935a33/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c253230352d627269676874677265656e3f7374796c653d666c6174)](https://camo.githubusercontent.com/9c993481c3bca6625658657a2812cdd8bec2daf7aae7cd224d244dfb77935a33/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c253230352d627269676874677265656e3f7374796c653d666c6174)

A Laravel package for implementing multi-tree hierarchical structures using the Nested Set Model.

Overview
--------

[](#overview)

This package supports Multi-Tree structures (multiple root nodes) and allows movement of nodes between trees. It works with various model primary key types: `int`, `uuid`, and `ulid`.

Key Advantages
--------------

[](#key-advantages)

- **Multi-Tree Support**: Manage multiple independent trees within the same table
- **Cross-Tree Operations**: Move nodes between different trees with ease
- **Flexible Primary Keys**: Works with various key types including `int`, `uuid`, and `ulid`
- **Comprehensive Tree Health Tools**: Built-in validation and repair utilities for tree integrity
- **Performance Optimized**: Efficiently retrieves hierarchical data with minimal database queries
- **Modern PHP Support**: Utilizes modern PHP 8.x features and strict typing
- **Flexible Configuration**: Highly customizable attribute naming and behavior
- **Well Documented**: Complete documentation with practical examples
- **Thoroughly Tested**: Comprehensive test suite ensuring reliability

### What are nested sets?

[](#what-are-nested-sets)

[Nested Set Model](http://en.wikipedia.org/wiki/Nested_set_model) is an efficient way to store hierarchical data in relational databases:

> The nested set model numbers nodes according to a tree traversal, which visits each node twice, assigning numbers in the order of visiting, and at both visits. This leaves two numbers for each node, which are stored as attributes. Querying becomes inexpensive: hierarchy membership can be tested by comparing these numbers. Updating requires renumbering and is therefore expensive.

### Ideal Use Cases

[](#ideal-use-cases)

NSM shows good performance when:

- Trees are updated infrequently
- Fast retrieval of related nodes is needed
- Building multi-depth menus or category structures

Visualization
-------------

[](#visualization)

 [![html tree](./docs/assets/tree.png)](./docs/assets/tree.png) [![console tree](./docs/assets/table.png)](./docs/assets/table.png)

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

[](#requirements)

- PHP: 8.2|8.3|8.4|8.5
- Laravel: ^11.*, ^12.*

It is highly recommended to use a database that supports transactions (like PostgreSQL) to protect tree structures from corruption.

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

[](#installation)

```
composer require efureev/laravel-trees
```

Documentation
-------------

[](#documentation)

- [Basic Usage](./docs/Basic.md)
- [Advanced Tree Configuration](./docs/AdvancedTreeConfig.md)
- [Database Migration](./docs/Migration.md)
- [Creating Nodes](./docs/CreatingNodes.md)
- [Managing Nodes](./docs/ManagingNodes.md)
- [Retrieving Nodes](./docs/ReceivingNodes.md)
- [Model Helpers](./docs/Helpers.md)
- [Console Commands](./docs/Console.md)
- [Health Checks and Fixing](./docs/HealthAndFix.md)

Testing
-------

[](#testing)

```
./vendor/bin/phpunit --testdox
# or
composer test
```

###  Health Score

67

—

FairBetter than 100% of packages

Maintenance89

Actively maintained with recent releases

Popularity46

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity89

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 94.4% 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 ~29 days

Recently: every ~53 days

Total

90

Last Release

54d ago

Major Versions

v1.7.5 → v2.0.02020-05-18

v2.5.0 → v3.0.02021-04-28

v3.8.4 → v4.0.02024-03-14

v4.0.0 → v5.0.0-rc12024-04-02

v5.0.0 → v6.x-dev2024-12-25

PHP version history (9 changes)v2.0.2PHP &gt;=7.4

v2.2.0PHP ^7.4|^8.0

v3.0.0PHP ^8.0

v3.7.0PHP ^8.0|^8.1

v3.8.0PHP ^8.0|^8.1|^8.2

v4.0.0PHP ^8.2|^8.3

v6.x-devPHP ^8.4

v5.1.0PHP ^8.2|^8.3|^8.4

v5.2.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/62a6e061d1ccab4d5de8dcba717b7634f91e4842b32ca26420b8261c66104bf7?d=identicon)[efureev](/maintainers/efureev)

---

Top Contributors

[![efureev](https://avatars.githubusercontent.com/u/5524684?v=4)](https://github.com/efureev "efureev (153 commits)")[![dikopylov](https://avatars.githubusercontent.com/u/38421064?v=4)](https://github.com/dikopylov "dikopylov (2 commits)")[![veelasky](https://avatars.githubusercontent.com/u/1797358?v=4)](https://github.com/veelasky "veelasky (2 commits)")[![mpge](https://avatars.githubusercontent.com/u/3311227?v=4)](https://github.com/mpge "mpge (1 commits)")[![bistory](https://avatars.githubusercontent.com/u/108102?v=4)](https://github.com/bistory "bistory (1 commits)")[![ZinoviL](https://avatars.githubusercontent.com/u/9405816?v=4)](https://github.com/ZinoviL "ZinoviL (1 commits)")[![imanghafoori1](https://avatars.githubusercontent.com/u/6961695?v=4)](https://github.com/imanghafoori1 "imanghafoori1 (1 commits)")[![Khazhinov](https://avatars.githubusercontent.com/u/15653986?v=4)](https://github.com/Khazhinov "Khazhinov (1 commits)")

---

Tags

laravelnestedsetphptreetree-structurephplaravelpackagetreemulti-tree

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/efureev-laravel-trees/health.svg)

```
[![Health](https://phpackages.com/badges/efureev-laravel-trees/health.svg)](https://phpackages.com/packages/efureev-laravel-trees)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[nunomaduro/essentials

Just better defaults for your Laravel projects.

1.2k317.5k51](/packages/nunomaduro-essentials)[laragear/preload

Effortlessly make a Preload script for your Laravel application.

119363.5k](/packages/laragear-preload)[netojose/laravel-bootstrap-4-forms

Bootstrap 4 form builder for Laravel 5

182115.3k](/packages/netojose-laravel-bootstrap-4-forms)[tehwave/laravel-achievements

Simple, elegant Achievements the Laravel way

7012.8k](/packages/tehwave-laravel-achievements)[wujunze/money-wrapper

MoneyPHP Wrapper

113.8k](/packages/wujunze-money-wrapper)

PHPackages © 2026

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