Example #1
0
 function subgroups($depth = -1, $withSelf = true)
 {
     $all = $next = array($this);
     while ($next and --$depth != 0) {
         $next = static::where_in('parent', prop('id', $next))->get();
         $all = array_merge($all, $next);
     }
     return $withSelf ? $all : S::slice($all);
 }