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

+ 21 - 20
server/app/Http/Controllers/Api/V1/IndexController.php

@@ -43,18 +43,20 @@ class IndexController extends Controller
      *       }
      *       }
      *   ],
      *   ],
      *   "users": [                  动态用户
      *   "users": [                  动态用户
-     *       {
-     *           "id": 3,
-     *           "user_id": 1,
-     *           "other_user_id": 2,
-     *           "dream_number": 1,
-     *           "created_at": null,
-     *           "updated_at": null,
-     *            "other_user": {
-     *               "id": 2,
-     *               "avatar": "http://www.miao.com/upload/user/20170630/08e235d7211944e9b6482965b4d7c42e.jpg",
-     *           }
-     *       }
+     *      {
+     *          "id": 3,
+     *          "user_id": 1,
+     *          "other_user_id": 2,
+     *          "dream_number": 1,    >0 表示有最新动态
+     *          "created_at": null,
+     *          "updated_at": null,
+     *          "other_user": {
+     *              "id": 2,
+     *              "phone": "13880642881",
+     *              "nickname": "name2",
+     *              "avatar": "http://www.miao.com/upload/user/20170630/08e235d7211944e9b6482965b4d7c42e.jpg",
+     *          }
+     *      },
      *  ],
      *  ],
      *   "dreams": {
      *   "dreams": {
      *       "current_page": 1,
      *       "current_page": 1,
@@ -116,19 +118,18 @@ class IndexController extends Controller
         $id_arr1 = array_column($arr1,'id');
         $id_arr1 = array_column($arr1,'id');
         $arr2 =DreamInfoModel::orderBy('score','desc')->offset(15)->limit(120)->select('id')->get()->toArray();
         $arr2 =DreamInfoModel::orderBy('score','desc')->offset(15)->limit(120)->select('id')->get()->toArray();
         $id_arr2 = array_column($arr2,'id');
         $id_arr2 = array_column($arr2,'id');
-        $dtusers =UserCareUser::where('user_id',$id)->with('other_user')->
-        where('dream_number','>',0)->orderBy('created_at')->get()->toArray();
-        $hdusers = CommentInfoModel::where(function ($query) use ($id) {
+        $users =UserCareUser::where('user_id',$id)->with('other_user')->orderBy('dream_number','desc')->get()->toArray();
+      /*  $hdusers = CommentInfoModel::where(function ($query) use ($id) {
 //            $query->where('user_id',$id)->orWhere('to_user_id',$id);
 //            $query->where('user_id',$id)->orWhere('to_user_id',$id);
             $query->where('user_id',$id);
             $query->where('user_id',$id);
-        })->where('is_read',0)->with('to_user')->orderBy('created_at')->get()->toArray();
-        $users = [] ;
+        })->where('is_read',0)->with('to_user')->orderBy('created_at')->get()->toArray();*/
+        /*$users = [] ;
         foreach ($dtusers as $k => $v){
         foreach ($dtusers as $k => $v){
             $users[] = $v['other_user'];
             $users[] = $v['other_user'];
-        }
-        foreach ($hdusers as $k => $v){
+        }*/
+      /*  foreach ($hdusers as $k => $v){
             $users[] = $v['to_user'];
             $users[] = $v['to_user'];
-        }
+        }*/
         $type = $request->type;
         $type = $request->type;
         if ($type == 'trend') {
         if ($type == 'trend') {
             $dreams = DreamInfoModel::orderBy('score','desc')->with('user')->whereNotIn('id', $id_arr1)->limit(100)->paginate(20);
             $dreams = DreamInfoModel::orderBy('score','desc')->with('user')->whereNotIn('id', $id_arr1)->limit(100)->paginate(20);