|
@@ -42,7 +42,7 @@ class IndexController extends Controller
|
|
* "deleted_at": null
|
|
* "deleted_at": null
|
|
* }
|
|
* }
|
|
* ],
|
|
* ],
|
|
- * "dtusers": [ 动态用户
|
|
|
|
|
|
+ * "users": [
|
|
* {
|
|
* {
|
|
* "id": 3,
|
|
* "id": 3,
|
|
* "user_id": 1,
|
|
* "user_id": 1,
|
|
@@ -50,13 +50,12 @@ class IndexController extends Controller
|
|
* "dream_number": 1,
|
|
* "dream_number": 1,
|
|
* "created_at": null,
|
|
* "created_at": null,
|
|
* "updated_at": null,
|
|
* "updated_at": null,
|
|
- * "other_user": { 动态用户 头像和id
|
|
|
|
|
|
+ * "other_user": {
|
|
* "id": 2,
|
|
* "id": 2,
|
|
* "avatar": "http://www.miao.com/upload/user/20170630/08e235d7211944e9b6482965b4d7c42e.jpg",
|
|
* "avatar": "http://www.miao.com/upload/user/20170630/08e235d7211944e9b6482965b4d7c42e.jpg",
|
|
* }
|
|
* }
|
|
* }
|
|
* }
|
|
* ],
|
|
* ],
|
|
- * "hdusers": [], 互动用户
|
|
|
|
* "dreams": {
|
|
* "dreams": {
|
|
* "current_page": 1,
|
|
* "current_page": 1,
|
|
* "data": [
|
|
* "data": [
|
|
@@ -122,20 +121,27 @@ class IndexController extends Controller
|
|
$hdusers = CommentInfoModel::where(function ($query) use ($id) {
|
|
$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);
|
|
})->where('is_read',0)->with('to_user')->orderBy('created_at')->get()->toArray();
|
|
})->where('is_read',0)->with('to_user')->orderBy('created_at')->get()->toArray();
|
|
|
|
+ $users = [] ;
|
|
|
|
+ foreach ($dtusers as $k => $v){
|
|
|
|
+ $users[] = $v['other_user'];
|
|
|
|
+ }
|
|
|
|
+ foreach ($hdusers as $k => $v){
|
|
|
|
+ $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);
|
|
$this->dreams($dreams);
|
|
$this->dreams($dreams);
|
|
- return $this->api(compact('dtusers','hdusers','dreams'));
|
|
|
|
|
|
+ return $this->api(compact('users','dreams'));
|
|
} elseif ($type == 'news') {
|
|
} elseif ($type == 'news') {
|
|
$dreams = DreamInfoModel::orderBy('score','desc')->orderBy('created_at','desc')->with('user')->whereNotIn('id', $id_arr2)->limit(500)->paginate(20);
|
|
$dreams = DreamInfoModel::orderBy('score','desc')->orderBy('created_at','desc')->with('user')->whereNotIn('id', $id_arr2)->limit(500)->paginate(20);
|
|
$this->dreams($dreams);
|
|
$this->dreams($dreams);
|
|
- return $this->api(compact('dtusers','hdusers','dreams'));
|
|
|
|
|
|
+ return $this->api(compact('users','dreams'));
|
|
} else{
|
|
} else{
|
|
$banners = $this->getBanner();
|
|
$banners = $this->getBanner();
|
|
$dreams = DreamInfoModel::orderBy('score','desc')->with('user')->limit(20)->paginate(20);
|
|
$dreams = DreamInfoModel::orderBy('score','desc')->with('user')->limit(20)->paginate(20);
|
|
$this->dreams($dreams);
|
|
$this->dreams($dreams);
|
|
- return $this->api(compact('banners','dtusers','hdusers','dreams'));
|
|
|
|
|
|
+ return $this->api(compact('banners','users','dreams'));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|