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
3.5.0

Added

  • Added support for Laravel 13.
3.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().
3.3.1

Fixed

  • Fixed backward compatibility issue when using deleteTree().
3.3.0

Added

  • Added support for Laravel 12.
  • Added support for other DBMSs: SQLite, PostgreSQL, SQL Server. Only MySQL was supported in previous versions.
3.2.0

Added

  • Added support for Laravel 11.
3.1.1

Fixed

  • The getTree() method, when called on an ordered tree, now orders the root elements.
3.1.0

Added

  • Added support for Laravel 10.
3.0.0

Added

  • Added support for Laravel 9.
2.0.2

Fixed

  • Fixed implicit transaction commit in bonsai:fix command.
2.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.
2.0.0

Added

  • Added support for Laravel 8.

Removed

  • Dropped support for Laravel 6/7.
1.0.0

First stable release.

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.
steadrun/laravel-monitor
labyrinthe/connect-laravel
elmogy/layan
drewdan/sentinel-client
dskripchenko/laravel-llm
fatryst/nuonuo
stevenay/myanfont
gmostafa/php-graphql-client
xeviant/paystack
snowsoft/faker
meditationsteps/blogetc
animalyoung/laravel-influxdb
onix-solutions/sms-telera
lonely-lights/prosetta
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin