gq hace 7 años
padre
commit
d66a3e5e64

+ 1 - 1
server/app/Http/Controllers/Api/V1/Controller.php

xqd
@@ -20,8 +20,8 @@ class Controller extends BaseController
 
     public function getUser()
     {
-//        $this->user = UserInfoModel::where('phone','13880642880')->first();
         $this->user = Auth::guard('api')->user();
+//        $this->user = UserInfoModel::where('phone','13880642880')->first();
         return $this->user;
     }
 

+ 51 - 0
server/app/Http/Controllers/Api/V1/MyController.php

xqd
@@ -861,6 +861,57 @@ class MyController extends Controller
         $users =$user->UserCareUser;
         return $this->api($users);
 
+    }
+    /**
+     * @api {get} /api/my/careme 关注我的用户
+     * @apiDescription 关注我的用户
+     * @apiGroup My
+     * @apiPermission Passport
+     * @apiVersion 0.1.0
+     * @apiSuccessExample {json} Success-Response:
+     * HTTP/1.1 200 OK
+     *{
+     *   "status": true,
+     *   "status_code": 0,
+     *  "message": "",
+     *   "data":[] or
+     *   "data": [
+     *      {
+     *           "id": 2,
+     *           "phone": "13880642881",
+     *          "nickname": "name2",
+     *          "avatar": "http://www.miao.com/upload/user/20170630/08e235d7211944e9b6482965b4d7c42e.jpg",
+     *          "birthday": "2000-06-21",
+     *          "sign": 0,
+     *          "money": 0,
+     *          "coin": 800,
+     *          "sex": 1,
+     *          "signture": "我的个性签名2",
+     *          "height": 200,
+     *          "work": "兼职",
+     *          "emotion": 2,
+     *          "address": "370105",
+     *          "city": "成都",
+     *          "detail_address": "",
+     *          "status": 1,
+     *          "wechat": "",
+     *          "weibo": "",
+     *          "remember_token": "",
+     *          "created_at": "2017-06-25 10:42:06",
+     *          "updated_at": "2017-06-30 09:15:04",
+     *          "deleted_at": null,
+     *      }
+     *  ]
+     *}
+     * @apiErrorExample {json} Error-Response:
+     * HTTP/1.1 400 Bad Request
+     */
+    public function careMe()
+    {
+        $user = $this->getUser();
+        $users =$user->UserCareMe;
+        return $this->api($users);
+
     }
 
     public function insertSearchTable($id,$keyword)

+ 6 - 0
server/app/Models/UserInfoModel.php

xqd
@@ -63,6 +63,12 @@ class UserInfoModel extends Authenticatable
     {
         return $this->belongsToMany('App\Models\UserInfoModel','user_care_user','user_id','other_user_id');
     }
+
+    public function UserCareMe()
+    {
+        return $this->belongsToMany('App\Models\UserInfoModel','user_care_user','other_user_id','user_id');
+    }
+
     public function UserCareDream()
     {
         return $this->belongsToMany('App\Models\DreamInfoModel','user_care_dream','user_id','dream_id')->with(['user'])->withPivot('interaction_number','dream_user_id')->orderBy('updated_at');

+ 4 - 0
server/routes/api.php

xqd
@@ -154,6 +154,10 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         'as' => 'my.care',
         'uses' => 'MyController@care',
     ]);
+    $api->get('my/careme', [
+        'as' => 'my.careme',
+        'uses' => 'MyController@careMe',
+    ]);
 //    我的收藏
     $api->get('my/collection', [
         'as' => 'my.collection',