A Laravel Eloquent implementation of the Nested Set pattern for efficient hierarchical data management.
Baum is a Laravel package that implements the Nested Set model for the Eloquent ORM. It provides a robust solution for managing hierarchical data structures like menus, categories, or threaded posts, enabling fast, non-recursive queries for tree operations.
Laravel developers building applications that require efficient management of hierarchical data, such as e-commerce platforms with nested categories, content management systems with threaded comments, or any system needing tree-like structures.
Developers choose Baum because it abstracts the complex SQL of the Nested Set pattern into an intuitive, Laravel-friendly API, offering performance advantages like single-query retrieval of descendants/ancestors and seamless integration with Eloquent features like relations, scopes, and events.
Baum is an implementation of the Nested Set pattern for Laravel's Eloquent ORM.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Leverages the Nested Set model to fetch all descendants or ancestors in a single query using lft and rgt columns, enabling fast reads regardless of tree depth.
Provides intuitive methods like makeChildOf and moveToLeftOf for moving, inserting, and deleting nodes, abstracting complex SQL operations into a clean API.
Allows multiple independent trees in the same table via scope columns like company_id, ideal for multi-tenant applications where each tenant has its own hierarchy.
Includes isValidNestedSet() to check tree integrity and rebuild() to reindex corrupted or imported parent-child data, ensuring data consistency.
The README admits soft deletes have 'limited support,' with safe restore operations restricted to leaf nodes or subtrees where the parent isn't soft-deleted, which can be problematic.
Baum does not support moving nodes between trees with different scope values, limiting flexibility in scenarios like reorganizing multi-tenant data.
The Nested Set model requires updating multiple rows' lft and rgt values for insertions, deletions, and moves, which can degrade performance in write-intensive applications.