gq 7 年之前
父節點
當前提交
f0a5acf0e4
共有 1 個文件被更改,包括 43 次插入27 次删除
  1. 43 27
      server/app/Http/Controllers/Api/V1/MyController.php

+ 43 - 27
server/app/Http/Controllers/Api/V1/MyController.php

xqd xqd
@@ -260,7 +260,8 @@ class MyController extends Controller
             $item->update(['is_read'=>0]);
         }
         return $this->api($data);
-    } /**
+    }
+    /**
      * @api {get} /api/my/letter 私信
      * @apiDescription 私信
      * @apiGroup My
@@ -613,38 +614,53 @@ class MyController extends Controller
      * @apiVersion 0.1.0
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 OK
-     *{
-     *   "status": true,
-     *   "status_code": 0,
-     *   "message": "",
-     *   "data": [
-     *       {
-     *           "id": 5,
-     *           "user_id": 1,
-     *           "name": "梦想标题1",
-     *           "about": "梦想介绍",
-     *           "coin": 2500,
-     *           "time": 21,
-     *            "get_coin": 0,
-     *           "status": 0,
-     *           "video": null,
-     *           "sign": "",
-     *           "created_at": "2017-06-25 12:45:22",
-     *            "updated_at": "2017-06-25 12:45:22",
-     *           "pic": "https://timgsa.baidu.com/timg?image7b14f12f.jpg",
-     *       },
-     *   ]
-     *}
+    {
+        "status": true,
+        "status_code": 0,
+        "message": "",
+        "data": {
+            "current_page": 1,
+            "data": [
+                {
+                    "id": 32,
+                    "user_id": 1,
+                    "name": "name",
+                    "about": "13880642880",
+                    "coin": 100,
+                    "end_time": "0000-00-00 00:00:00",
+                    "get_coin": 2017,
+                    "mark": 100,
+                    "status": 127,
+                    "video": "0",
+                    "score": 0,
+                    "sign": "158730",
+                    "code": "http://www.miao.com/qrcodes/WECHATPAY_201708191324294255.png",
+                    "parameter": 0,
+                    "created_at": "2017-08-19 05:22:12",
+                    "updated_at": "2017-08-19 05:24:30",
+                    "img": {
+                        "title": "",
+                        "pic": "http://q8.9026.com/upload/dream/20170629/79c11614cc8a9d37f747e3974d055331.jpg"
+                    }
+                },
+            ],
+            "from": 1,
+            "last_page": 4,
+            "next_page_url": "http://www.miao.com/api/my/dream?page=2",
+            "path": "http://www.miao.com/api/my/dream",
+            "per_page": 10,
+            "prev_page_url": null,
+            "to": 10,
+            "total": 36
+        }
+    }
      * @apiErrorExample {json} Error-Response:
      * HTTP/1.1 400 Bad Request
      */
     public function dream()
     {
         $user = $this->getUser();
-        $dreams = $user->dreams;
-        foreach ($dreams as $dream){
-            $dream->pic = count($dream->img) > 0 ? $dream->img->pic : '';
-        }
+        $dreams = DreamInfoModel::where('user_id',$user->id)->orderBy('created_at','desc')->with('img')->paginate();
         return $this->api($dreams);
     }