Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Nestedset Laravel Package

dagasmart/nestedset

Nested set implementation for Laravel Eloquent models. Store hierarchical trees in a flat table with fast ancestor, descendant, and sibling queries, plus node moves, reordering, and tree rebuilding—no recursive queries required.

Deep Wiki
Context7

dagasmart/nestedset is a Laravel package for storing and querying hierarchical data using the nested set model, where each node carries left and right boundary columns so entire subtrees can be fetched with a single query instead of recursive lookups. It provides a trait you add to an Eloquent model, giving you tree-aware relationships and query scopes while keeping your schema simple.

  • Efficient subtree and ancestor queries without recursion
  • Move, insert, and delete nodes while boundaries stay consistent
  • Tree traversal helpers: descendants, ancestors, siblings, roots, leaves
  • Eloquent relationships and scopes for building menus, categories, and comments
Frequently asked questions about Nestedset
What is dagasmart/nestedset used for in Laravel?
It is a Laravel package for managing hierarchical data using the nested set model. You can use it to build trees such as categories, menus, or organization structures. The package focuses on efficient ancestor and descendant queries plus straightforward node move and insert operations.
How do I install dagasmart/nestedset in a Laravel app?
Install it with Composer using composer require dagasmart/nestedset. Laravel package discovery should register the service provider automatically if the package supports it. Check the package README for any migration publishing, configuration, or model setup steps.
How does a nested set differ from a parent_id adjacency list in Laravel?
A nested set stores left and right boundary values so an entire subtree can be fetched with a range query. A parent_id adjacency list usually requires recursive queries or repeated database calls to walk the tree. Nested sets are often faster for reads but can be more expensive when moving nodes because multiple boundaries may need updating.
How do I query ancestors or descendants with dagasmart/nestedset?
The package is designed for efficient ancestor and descendant queries on nested set trees. Use the model relationships, scopes, or query helpers documented in the README rather than writing raw boundary conditions. This keeps your tree queries consistent with the package's column and scoping conventions.
How do I move a node or subtree in dagasmart/nestedset?
The package provides straightforward node move and insert operations for nested set trees. Use the documented move methods instead of manually changing left and right values. Because a move can update multiple rows, run it inside a transaction and verify the tree boundaries afterward.
Can dagasmart/nestedset handle multiple trees in one database table?
The provided overview describes nested set tree management but does not specify multi-tree scoping behavior. Check the README and model configuration for a tree or root column if you need separate trees in one table. Without documented scoping support, use separate tables or verify the package behavior before relying on it.
Which Laravel versions are supported by dagasmart/nestedset?
The package metadata provided here does not list Laravel version constraints. Check its composer.json on Packagist or the repository to confirm support for your Laravel and PHP versions. Test installation in a staging app before upgrading Laravel in production.
How should I test tree operations with dagasmart/nestedset?
Use Laravel's database testing tools with a fresh test database and build small fixtures with known tree shapes. Assert ancestor and descendant query results plus left and right boundary values after inserts and moves. Wrap move tests in transactions so failed assertions do not leave broken tree data behind.
Is dagasmart/nestedset maintained and safe for production use?
The prompt does not include repository activity, release history, or test coverage details, so verify those on Packagist and the source repository. Check recent commits, open issues, supported Laravel versions, and whether tests run in CI. Treat those signals as part of your production readiness review before adopting the package.
What are alternatives to dagasmart/nestedset for Laravel trees?
A well-known alternative is kalnoy/nestedset, which also implements nested sets for Laravel. You can also use a parent_id adjacency list with recursive queries or a closure table depending on your read and write patterns. Compare query performance, move complexity, maintenance activity, and Laravel version support before choosing.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console