creocoder/yii2-nested-sets
Yii2 Nested Sets Behavior implementing the Modified Preorder Tree Traversal algorithm for hierarchical data. Adds ActiveRecord behavior and query helpers for inserting, moving, and deleting nodes, with optional multi-tree support via a tree attribute.
ActiveQuery, Behavior system).laravel-nestedset, spatie/laravel-activitylog for soft-deletes, or custom closures).Model trait compatibility).Behavior system, which Laravel does not natively support.nicolaslopezj/searchable (for soft-deletes) or spatie/laravel-activitylog (for auditing) alongside a custom Nested Set solution.Behavior calls to Laravel’s Eloquent methods (high maintenance).Behavior-based updates).laravel-nestedset)?Behavior system? If not, a custom implementation may be riskier.ActiveRecord vs. Laravel’s Eloquent.DbCommand vs. Laravel’s Builder.Event system vs. Laravel’s Model Events.yii\base\Behavior, yii\db\BaseActiveRecord, etc.laravel-nestedset (abandoned but functional).spatie/laravel-activitylog + custom pivot tables.laravel-nestedset or fork it.insert/update with calculated lft/rgt values.Behavior-dependent code with Eloquent relationships/methods.Schema::table() for migrations, Artisan commands for data conversion.lft/rgt columns to the target table.boot() method in Eloquent model to handle creating/saving events.DB::update() with CTEs).// Model boot method
protected static function boot() {
parent::boot();
static::creating(function ($model) {
$model->lft = static::getNextLft();
$model->rgt = $model->lft + 1;
});
static::saved(function ($model) {
if ($model->isDirty('parent_id')) {
$model->reorder();
}
});
}
Model that wraps Yii2’s Behavior-like logic.Behavior calls.rgt - lft = 2 * nodes - 1).debugbar or telescope for query monitoring.Redis with laravel-redis).lft/rgt simultaneously).How can I help you explore Laravel packages today?