I found out that ->ancestors() not working, not sure that it is the right way to fix it, but that patch solves the problem:
in original (lazychaser/laravel-nestedset) QueryBuilder.php inside whereAncestorOf function I change
$inner->whereRaw("{$value} between {$lft} and {$rgt}");
to
$inner->where( "_lft" , "<=", $value );
$inner->where( "_rgt", ">=", $value );
not sure how to pass proper "{$lft}" value from variable here, it's not working after call to wrappedColumns.
With this patch it's possible to get current level ( instead of not working withDepth() ):
$item->ancestors()->get()->count();
Second issue is that when you turn on Scoping, all new root elements saved as [_lft,_rgt] = [1,2] and if parent_id set – everything crashed.
To fix that one I change in TreeTrait.php function applyNestedSetScope():
$query->where($table.'.'.$attribute, '=',
to
$query->where($attribute, '=',
Hi!
I found out that ->ancestors() not working, not sure that it is the right way to fix it, but that patch solves the problem: in original (lazychaser/laravel-nestedset) QueryBuilder.php inside whereAncestorOf function I change $inner->whereRaw("{$value} between {$lft} and {$rgt}"); to $inner->where( "_lft" , "<=", $value ); $inner->where( "_rgt", ">=", $value );
not sure how to pass proper "{$lft}" value from variable here, it's not working after call to wrappedColumns.
With this patch it's possible to get current level ( instead of not working withDepth() ): $item->ancestors()->get()->count();
Second issue is that when you turn on Scoping, all new root elements saved as [_lft,_rgt] = [1,2] and if parent_id set – everything crashed.
To fix that one I change in TreeTrait.php function applyNestedSetScope():
$query->where($table.'.'.$attribute, '=', to $query->where($attribute, '=',
Not sure why mongo do not like this table prefix.
Hope this helps!