Kirin 3 年之前
父節點
當前提交
8710341871
共有 2 個文件被更改,包括 4 次插入3 次删除
  1. 1 1
      app/api/controller/activity/TreeController.php
  2. 3 2
      app/models/tree/TreeRecommend.php

+ 1 - 1
app/api/controller/activity/TreeController.php

@@ -29,7 +29,7 @@ class TreeController
 
 
     public function pointChildren($id, Request $request)
     public function pointChildren($id, Request $request)
     {
     {
-        $children = TreeRecommend::with('user')->where('parent_id', $id)->order('way', 'asc')->select();
+        $children = TreeRecommend::with(['user'])->where('parent_id', $id)->order('way', 'asc')->select();
         return app('json')->success('ok', compact('children'));
         return app('json')->success('ok', compact('children'));
     }
     }
 }
 }

+ 3 - 2
app/models/tree/TreeRecommend.php

@@ -12,6 +12,7 @@ use think\db\exception\DataNotFoundException;
 use think\db\exception\DbException;
 use think\db\exception\DbException;
 use think\db\exception\ModelNotFoundException;
 use think\db\exception\ModelNotFoundException;
 use think\model\relation\HasMany;
 use think\model\relation\HasMany;
+use think\model\relation\HasOne;
 
 
 class TreeRecommend extends BaseModel
 class TreeRecommend extends BaseModel
 {
 {
@@ -40,9 +41,9 @@ class TreeRecommend extends BaseModel
         self::$get = sys_config('group_award', 135);
         self::$get = sys_config('group_award', 135);
     }
     }
 
 
-    public function user(): HasMany
+    public function user(): HasOne
     {
     {
-        return self::hasMany(User::class, 'uid', 'uid')->field('nickname,phone,avatar');
+        return $this->HasOne(User::class, 'uid', 'uid');
     }
     }
 
 
     /**
     /**