staudenmeir/laravel-adjacency-list
Laravel Eloquent extension for recursive tree and graph relationships using SQL common table expressions. Traverse ancestors, descendants, and paths in adjacency-list data across MySQL, Postgres, SQLite, SQL Server, and more; supports one-to-many trees and many-to-many graphs.
HasRecursiveRelationships) and optional method overrides (e.g., getParentKeyName()).enableCycleDetection() adds query complexity and may impact performance for large graphs.withMaxDepth() improves performance but requires careful handling to avoid incomplete results.slug_path) add flexibility but may introduce serialization/deserialization challenges in APIs.withMaxDepth usage.)enableCycleDetection() be required?path column sufficient?children relationships).Category or User).self-joins or materialized paths) with package methods (e.g., descendants()).HasRecursiveRelationships to additional models as needed.depth/path metadata if required.parent_id foreign keys) for CTE performance.Laravel-Nestedset).parent_id (or custom key) is indexed.with() eager loading), but recursive queries may bypass cache unless explicitly configured.parent_id (or equivalent) is nullable and indexed.HasRecursiveRelationships to target models.tree() instead of manual self-joins).withMaxDepth() and enable cycle detection as needed.ancestorsAndSelf).getParentKeyName()) may need updates if schema changes.DB::enableQueryLog() to inspect generated SQL.enableCycleDetection() is configured for graphs.withMaxDepth() for deep hierarchies.SELECT ... FOR UPDATE).version column) for parent-child updates.cursor() or simplePaginate() for large trees.descendants()->cursor()).tree()->remember(60)).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Database CTE limits exceeded | Query timeouts/failures | Use withMaxDepth() or shallow queries. |
| Cycles in graph data | Infinite loops | Enable enableCycleDetection(). |
| High memory usage | Out-of-memory errors | Use cursor() or chunking. |
| Concurrent tree modifications | Data corruption | Implement locking or optimistic concurrency. |
| Package version incompatibility | Runtime errors | Pin version in composer.json. |
| Missing indexes | Slow queries | Add indexes on parent_id and foreign keys. |
descendants(), toTree()).How can I help you explore Laravel packages today?