Baum/Node - get descendants from more than one id

时间:2018-05-28 18:46:27

标签: laravel eloquent nested-sets

I can get descendants from one ID like this:

    return $node = \App\Categories::where('id',41)
->first()
->getDescendants()->pluck('id');

I wonder if it's possible to get descendants of several ids with the same method?

I tried a "whereIn" like this but it doesn't work:

    return $node = \App\Categories::whereIn('id', array(41,94))
->get()
->getDescendants()
->pluck('id');

I believe ->get() returns a Collection and I haven't succeeded in using a Baum/Node function on a Collection. So I can only use them on single models? So, should I loop through the ids and use getDescendants() on each id, is that the recommended way to do it?

0 个答案:

没有答案