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

Bonsai Laravel Package

baril/bonsai

Closure Table pattern implementation for Laravel Eloquent that lets you store and query tree-like structures in a relational database. Provides fast ancestor and descendant lookups across all supported DBMSs, migration artisan commands, and an alternative to nested sets.

View on GitHub
Deep Wiki
Context7
v3.5.0

Added

  • Added support for Laravel 13.
v3.4.0

Changed

Most of the code has been rewritten, even though the public API remains backwards compatible.

Added

  • Soft-deleting models are now supported. The SoftDeletes trait provides specific methods (forceDeleteTree(), restoreTree()).
  • New siblings() relation.
  • New methods for easier tree manipulation: graft(), graftOnto(), cut().
  • New withHeight() scope.

Deprecated

All of these will be removed in the next major version:

  • The --migrate option of the bonsai:grow command is deprecated.
  • The BelongsToOrderedTree trait is deprecated in favor of the combination of the BelongsToTree and Ordered traits.
  • The static getTree() and getTreeDepth() methods are deprecated and will be replaced with something else in v4.
  • The deleteNode() method is deprecated because it didn't seem very useful.
  • The withAncestors() and withDescendants() scopes are deprecated in favor of just using the with() method.
  • Some methods and scopes have been renamed (the old name is still available for now, but deprecated):
    • whereIsRoot() becomes onlyRoots(),
    • whereIsLeaf() becomes onlyLeaves(),
    • whereHasChildren() becomes hasChildren(),
    • whereIsDescendantOf() becomes descendantsOf(),
    • whereIsAncestorOf() becomes ancestorsOf(),
    • includingSelf() becomes withSelf(),
    • excludingSelf() becomes withoutSelf(),
    • upToDepth() becomes maxDepth(),
    • getSubtreeDepth() becomes getHeight().

Fixed

  • The migration generated by bonsai:grow now works with any type of key (such as UUIDs). It used to assume that the id column was an integer.
  • The relation scopes (such as withSelf()) can now be called in the constraints callback when using withCount() or whereHas().
v3.3.1
  • Fixed: backward compatibility issue when using deleteTree()
v3.3.0
  • Added: support for Laravel 12
  • Added: support for other SGBDs (SQLite, PostgreSQL, SQL Server) (previous versions only supported MySQL)
v3.2.0

Added Laravel 11 support (issue #3).

v3.1.1

Fixed

  • The getTree() method, when called on an ordered tree, now orders the root elements (issue #1).
v3.1.0

Added Laravel 10 support.

v3.0.0

Added Laravel 9 support.

v2.0.2

Fixed

  • Fixed implicit transaction commit in bonsai:fix command.
v2.0.1

Fixed

  • The parent relationship is now properly auto-loaded when with('ancestors') is used. Previously, it would be loaded with wrong parents if the ancestors relationship was not ordered by ascending depth, or was filtered by some constraint.
v2.0.0

Laravel 8 support.

v1.0.0
v1.0.0-RC2

Added

  • deleteNode method.

Changed

  • whereIsDescendantOf / whereIsAncestorOf now accept a Model as parameter.

Fixed

  • Changed deleteTree implementation to avoid errors on bigger trees.
v1.0.0-RC1
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.
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log