An open API service indexing awesome lists of open source software.

https://github.com/tegos-article/article-laravel-managing-hierarchical-data

Managing Hierarchical Data in Laravel: Recursive, Adjacency List, and Nested Set Compared
https://github.com/tegos-article/article-laravel-managing-hierarchical-data

adjacency-list hierarchical-data laravel nested-set php

Last synced: 15 days ago
JSON representation

Managing Hierarchical Data in Laravel: Recursive, Adjacency List, and Nested Set Compared

Awesome Lists containing this project

README

        

# Managing Hierarchical Data in Laravel: Recursive, Adjacency List, and Nested Set Compared

![Managing Hierarchical Data in Laravel](assets/poster.jpg)

This article explores three practical strategies for handling hierarchical data in Laravel 12 APIs, using a realistic
dataset of 1,000 automotive part categories:

* **Recursive Eloquent Relationships** - Laravel-native and intuitive
* **Adjacency List with Recursive CTEs** - using [`staudenmeir/laravel-adjacency-list`](https://github.com/staudenmeir/laravel-adjacency-list)
* **Nested Set Model** - optimized for reads via [`kalnoy/nestedset`](https://github.com/lazychaser/laravel-nestedset)

You'll get practical code samples, sample API responses, and some reality-check benchmarks.
Whether you're building a category tree, comment system, or organizational chart, this guide will help you pick the
right approach.

🔗 **Read the article**: [Managing Hierarchical Data in Laravel](#)

💻 **View source code**: [github.com/tegos/laravel-hierarchical-data](https://github.com/tegos/laravel-hierarchical-data)