|
|
@@ -12,7 +12,18 @@ class TreeController
|
|
|
public function myPoint(Request $request)
|
|
|
{
|
|
|
$user = $request->user();
|
|
|
- $points = TreeRecommend::where('uid', $user['uid'])->order('add_time', 'asc')->select();
|
|
|
+ $points = TreeRecommend::where('uid', $user['uid'])->order('add_time', 'asc')->select()
|
|
|
+ ->each(function ($item) {
|
|
|
+ $children = [];
|
|
|
+ $father = [$item['id']];
|
|
|
+ $layer = 1;
|
|
|
+ while (count($father) && $layer <= 12) {
|
|
|
+ $father = TreeRecommend::where('parent_id', 'in', $children)->column('id');
|
|
|
+ if (count($father) > 0) $children = array_merge($children, $father);
|
|
|
+ $layer++;
|
|
|
+ }
|
|
|
+ $item['children_num'] = count($children);
|
|
|
+ });
|
|
|
return app('json')->success('ok', $points);
|
|
|
}
|
|
|
|