Can I use depthLimit()?
HeinKoZin opened this issue · 4 comments
HeinKoZin commented
I want to get descendants limit with 5 depth from current user.
xalaida commented
You can try this: whereDepth(operator: '<=', depth: 5)
HeinKoZin commented
Thanks, mate! It worked!
HeinKoZin commented
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.
xalaida commented
Hi. Try calculating the current depth somehow and add this to the query depth. For example
whereDepth(operator: '<=', depth: 20 + $auth->getPath()->getDepth())