xalaida/laravel-tree

Can I use depthLimit()?

HeinKoZin opened this issue · 4 comments

I want to get descendants limit with 5 depth from current user.

You can try this: whereDepth(operator: '<=', depth: 5)

Thanks, mate! It worked!

Hello mate,

When I used

User::query()->whereSelfOrDescendantOf($auth)->withTrashed()->whereDepth(operator: '<=', depth: 20)->get()

I got descendants list where depth 20 from root, not from current user.

How can I get whereDepth from current $auth user.

Hi. Try calculating the current depth somehow and add this to the query depth. For example

whereDepth(operator: '<=', depth: 20 + $auth->getPath()->getDepth())