|
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api\V1;
|
|
use App\Models\BaseSettingsModel;
|
|
use App\Models\BaseSettingsModel;
|
|
use App\Models\DreamInfoModel;
|
|
use App\Models\DreamInfoModel;
|
|
use App\Models\SearchInfoModel;
|
|
use App\Models\SearchInfoModel;
|
|
|
|
+use App\Models\UserCareDream;
|
|
use App\Models\UserCareUser;
|
|
use App\Models\UserCareUser;
|
|
use App\Models\UserDream;
|
|
use App\Models\UserDream;
|
|
use App\Models\UserInfoModel;
|
|
use App\Models\UserInfoModel;
|
|
@@ -24,52 +25,142 @@ class IndexController extends Controller
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* HTTP/1.1 200 OK
|
|
* HTTP/1.1 200 OK
|
|
*{
|
|
*{
|
|
- *"status": true,
|
|
|
|
- *"status_code": 0,
|
|
|
|
- *"message": "",
|
|
|
|
- *"data": {
|
|
|
|
- * "banner": [], 轮播图
|
|
|
|
- * "users": [ 动态用户
|
|
|
|
- * 'news_num':2 新消息数目
|
|
|
|
- * ],
|
|
|
|
- * "dreams": {
|
|
|
|
- * "current_page": 1,
|
|
|
|
- * "data": [
|
|
|
|
|
|
+ * "status": true,
|
|
|
|
+ * "status_code": 0,
|
|
|
|
+ * "message": "",
|
|
|
|
+ * "data": {
|
|
|
|
+ * "banner": [ 轮播图
|
|
|
|
+ * {
|
|
|
|
+ * "value": "http://w17.9026.com/img/banner/banner_2.png",
|
|
|
|
+ * },
|
|
|
|
+ * {
|
|
|
|
+ * "value": "http://w17.9026.com/img/banner/banner_3.png",
|
|
|
|
+ * },
|
|
|
|
+ * ],
|
|
|
|
+ * "users": {
|
|
|
|
+ * "1": [ 1用户ID
|
|
|
|
+ * [
|
|
|
|
+ * { 用户梦想互动
|
|
|
|
+ * "id": 8,
|
|
|
|
+ * "dream_id": 1,
|
|
|
|
+ * "title": "2",
|
|
|
|
+ * "pic1": "www.buniang.com",
|
|
|
|
+ * "pic2": "",
|
|
|
|
+ * "pic3": "",
|
|
|
|
+ * "pic4": "",
|
|
|
|
+ * "pic5": "",
|
|
|
|
+ * "pic6": "",
|
|
|
|
+ * "pic7": "",
|
|
|
|
+ * "pic8": "",
|
|
|
|
+ * "pic9": "",
|
|
|
|
+ * "status": 1,
|
|
|
|
+ * "created_at": "2017-06-23 08:13:39",
|
|
|
|
+ * "updated_at": "2017-06-23 08:13:39",
|
|
|
|
+ * "deleted_at": null,
|
|
|
|
+ * "user_id": 1
|
|
|
|
+ * },
|
|
* {
|
|
* {
|
|
- * "dream": "signture",
|
|
|
|
- * "about": "123568",
|
|
|
|
- * "video": "",
|
|
|
|
- * "money": 162,
|
|
|
|
- * "time": 2666,
|
|
|
|
- * "get_money": 0,
|
|
|
|
- * "status": 0,
|
|
|
|
- * "updated_at": "2017-06-21 10:51:20",
|
|
|
|
- * "dream_user":
|
|
|
|
- * {
|
|
|
|
- * "pic": "",
|
|
|
|
- * }
|
|
|
|
- * ,
|
|
|
|
- * "care_num": 1,
|
|
|
|
- * "dream_first_pic": null,
|
|
|
|
- * "dream_imgs_first": null 封面图片
|
|
|
|
- * "care_num": 2,
|
|
|
|
- * "dream_first_pic": null,
|
|
|
|
- * "dream_imgs_first": null
|
|
|
|
|
|
+ * "id": 9,
|
|
|
|
+ * "dream_id": 1,
|
|
|
|
+ * "title": "2haha",
|
|
|
|
+ * "pic1": "www.buniang.com",
|
|
|
|
+ * "pic2": "",
|
|
|
|
+ * "pic3": "",
|
|
|
|
+ * "pic4": "",
|
|
|
|
+ * "pic5": "",
|
|
|
|
+ * "pic6": "",
|
|
|
|
+ * "pic7": "",
|
|
|
|
+ * "pic8": "",
|
|
|
|
+ * "pic9": "",
|
|
|
|
+ * "status": 1,
|
|
|
|
+ * "created_at": "2017-06-23 08:15:01",
|
|
|
|
+ * "updated_at": "2017-06-23 08:15:01",
|
|
|
|
+ * "deleted_at": null,
|
|
|
|
+ * "user_id": 1
|
|
|
|
+ * },
|
|
|
|
+ * ],
|
|
|
|
+ * "http://www.wsfjq.com/photos/bd119684755.jpg" 用户头像
|
|
|
|
+ * 3 新消息条数
|
|
|
|
+ * ],
|
|
|
|
+ *}
|
|
|
|
+ * "dreams": { 梦想列表
|
|
|
|
+ * "current_page": 1,
|
|
|
|
+ * "data": [
|
|
|
|
+ * {
|
|
|
|
+ * "id": 1,
|
|
|
|
+ * "user_id": 1,
|
|
|
|
+ * "dream": "梦想标题",
|
|
|
|
+ * "about": "梦想烧",
|
|
|
|
+ * "video": "",
|
|
|
|
+ * "money": 10000,
|
|
|
|
+ * "time": 720000,
|
|
|
|
+ * "get_money": 0,
|
|
|
|
+ * "status": 0,
|
|
|
|
+ * "updated_at": "2017-06-22 09:42:41",
|
|
|
|
+ * "dream_user": { 梦想所有者
|
|
|
|
+ * "nickname": "ha",
|
|
|
|
+ * "pic": "http://www.wsfjq.com/photos/bd119684755.jpg",
|
|
|
|
+ * "money": 123568,
|
|
|
|
+ * "sex": 1,
|
|
|
|
+ * "signture": "signture",
|
|
|
|
+ * "city": "",
|
|
|
|
+ * "birthday": "2017-06-21",
|
|
|
|
+ * "status": 1,
|
|
|
|
+ * },
|
|
|
|
+ * "care_num": 1, 关注人数
|
|
|
|
+ * "dream_imgs_first": { 梦想封面图片
|
|
|
|
+ * "title": "",
|
|
|
|
+ * "pic": "http://w17.9026.com/img/banner/banner_3.png"
|
|
|
|
+ * },
|
|
|
|
+ * "dream_detailed": { 点击进入梦想详情
|
|
|
|
+ * "dream_imgs": [
|
|
|
|
+ * {
|
|
|
|
+ * "title": "",
|
|
|
|
+ * "pic": "http://w17.9026.com/img/banner/banner_3.png"
|
|
* },
|
|
* },
|
|
- * }
|
|
|
|
- * ],
|
|
|
|
- * "from": 1,
|
|
|
|
- * "last_page": 1,
|
|
|
|
- * "next_page_url": null,
|
|
|
|
- * "path": "http://www.miao.com/api/index/index",
|
|
|
|
- * "per_page": 20,
|
|
|
|
- * "prev_page_url": null,
|
|
|
|
- * "to": 3,
|
|
|
|
- * "total": 3
|
|
|
|
- * }
|
|
|
|
- * ]
|
|
|
|
|
|
+ * {
|
|
|
|
+ * "title": "",
|
|
|
|
+ * "pic": "http://w17.9026.com/img/banner/banner_3.png"
|
|
|
|
+ * }
|
|
|
|
+ * ],
|
|
|
|
+ * "comments": [
|
|
|
|
+ * {
|
|
|
|
+ * "user_id": 2,
|
|
|
|
+ * "level": 0,
|
|
|
|
+ * "content": "EST评论",
|
|
|
|
+ * "updated_at": null,
|
|
|
|
+ * "pic": "http://www.wsfjq.com/photos/bd119684755.jpg", 评论者头像
|
|
|
|
+ * "replay": [
|
|
|
|
+ * {
|
|
|
|
+ * "user_id": 2,
|
|
|
|
+ * "level": 0,
|
|
|
|
+ * "content": "拉了",
|
|
|
|
+ * "updated_at": null,
|
|
|
|
+ * "pic": "http://www.wsfjq.com/photos/bd119684755.jpg" 回复者头像
|
|
|
|
+ * },
|
|
|
|
+ * {
|
|
|
|
+ * "user_id": 3,
|
|
|
|
+ * "level": 0,
|
|
|
|
+ * "content": "userid3回复了你的消息",
|
|
|
|
+ * "updated_at": null,
|
|
|
|
+ * "pic": "http://www.wsfjq.com/photos/bd119684755.jpg"
|
|
|
|
+ * }
|
|
|
|
+ * ]
|
|
|
|
+ * },
|
|
|
|
+ * }
|
|
|
|
+ * ]
|
|
|
|
+ * },
|
|
|
|
+ * "from": 1,
|
|
|
|
+ * "last_page": 1,
|
|
|
|
+ * "next_page_url": null,
|
|
|
|
+ * "path": "http://www.miao.com/api/index/index",
|
|
|
|
+ * "per_page": 20,
|
|
|
|
+ * "prev_page_url": null,
|
|
|
|
+ * "to": 8,
|
|
|
|
+ * "total": 8
|
|
* }
|
|
* }
|
|
- * }
|
|
|
|
|
|
+ * }
|
|
|
|
+ *}
|
|
* @apiErrorExample {json} Error-Response:
|
|
* @apiErrorExample {json} Error-Response:
|
|
* HTTP/1.1 400 Bad Request
|
|
* HTTP/1.1 400 Bad Request
|
|
* {
|
|
* {
|
|
@@ -82,30 +173,41 @@ class IndexController extends Controller
|
|
public function index(Request $request)
|
|
public function index(Request $request)
|
|
{
|
|
{
|
|
$user = $this->getUser();
|
|
$user = $this->getUser();
|
|
- // 关注的用户
|
|
|
|
- $arr = $user->UserCareUser;
|
|
|
|
- $users = [] ;
|
|
|
|
- foreach ($arr as $k => $v){
|
|
|
|
- if ($v->pivot->dream_num > 0) {
|
|
|
|
- $v->news_num = $v->pivot->dream_num;
|
|
|
|
- $users[] = $v;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ // 关注的梦想
|
|
|
|
+ $users = $user->UserCareDream;
|
|
|
|
+// $arr = UserInfoModel::where('id',$user->id)->whereHas('UserCareDream', function ($query) {
|
|
|
|
+// $query->where('interaction_number', '>', 0);
|
|
|
|
+// })->get();
|
|
|
|
+// dd($arr->toArray());
|
|
|
|
+// $users = [] ;
|
|
|
|
+// $arr1 = [];
|
|
|
|
+// foreach ($arr as $k => $v){
|
|
|
|
+// if ($v->pivot->interaction_number > 0) {
|
|
|
|
+// if (!array_key_exists($v->pivot->dream_user_id,$arr1)) {
|
|
|
|
+// $arr1[$v->pivot->dream_user_id] = $v->pivot->interaction_number;
|
|
|
|
+// }else{
|
|
|
|
+// $arr1[$v->pivot->dream_user_id] += $v->pivot->interaction_number;
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// dd($arr1);
|
|
|
|
+// foreach ($arr1 as $k => $v){
|
|
|
|
+// $a = UserInfoModel::find($k);
|
|
|
|
+// $users[$k] =[$a->allInteraction,$a->pic,$v] ;
|
|
|
|
+// }
|
|
$type = $request->type;
|
|
$type = $request->type;
|
|
if ($type == 'trend') {
|
|
if ($type == 'trend') {
|
|
$dreams = DreamInfoModel::orderBy('score','desc')->offset(20)->limit(100)->paginate(20);
|
|
$dreams = DreamInfoModel::orderBy('score','desc')->offset(20)->limit(100)->paginate(20);
|
|
- $this->dreams($dreams);
|
|
|
|
return $this->api(compact('users','dreams'));
|
|
return $this->api(compact('users','dreams'));
|
|
} elseif ($type == 'news') {
|
|
} elseif ($type == 'news') {
|
|
$dreams = DreamInfoModel::orderBy('score','desc')->offset(100)->limit(500)->paginate(20);
|
|
$dreams = DreamInfoModel::orderBy('score','desc')->offset(100)->limit(500)->paginate(20);
|
|
- $this->dreams($dreams);
|
|
|
|
return $this->api(compact('users','dreams'));
|
|
return $this->api(compact('users','dreams'));
|
|
} else{
|
|
} else{
|
|
- $banner = $this->getBanner();
|
|
|
|
|
|
+ $banners = $this->getBanner();
|
|
// 获取其他用户信息 及梦想
|
|
// 获取其他用户信息 及梦想
|
|
$dreams = DreamInfoModel::orderBy('score','desc')->limit(20)->paginate(20);
|
|
$dreams = DreamInfoModel::orderBy('score','desc')->limit(20)->paginate(20);
|
|
$this->dreams($dreams);
|
|
$this->dreams($dreams);
|
|
- return $this->api(compact('banner','users','dreams'));
|
|
|
|
|
|
+ return $this->api(compact('banners','users','dreams'));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -116,7 +218,7 @@ class IndexController extends Controller
|
|
* @apiGroup Index
|
|
* @apiGroup Index
|
|
* @apiPermission none
|
|
* @apiPermission none
|
|
* @apiVersion 0.1.0
|
|
* @apiVersion 0.1.0
|
|
- * @apiParam {string} keyword 关键字可选
|
|
|
|
|
|
+ * @apiParam {string} keyword 关键字可选 (ha)
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* HTTP/1.1 200 OK
|
|
* HTTP/1.1 200 OK
|
|
* get
|
|
* get
|
|
@@ -159,15 +261,15 @@ class IndexController extends Controller
|
|
{
|
|
{
|
|
$user = $this->getUser();
|
|
$user = $this->getUser();
|
|
$keyword ='%'.$request->keyword.'%';
|
|
$keyword ='%'.$request->keyword.'%';
|
|
- $data1 = UserInfoModel::where('nickname','like',$keyword)->paginate(20);
|
|
|
|
|
|
+ $data1 = UserInfoModel::where('nickname','like',$keyword)->get();
|
|
$data2 = DreamInfoModel::where('dream','like',$keyword)->
|
|
$data2 = DreamInfoModel::where('dream','like',$keyword)->
|
|
- orWhere('dream','like',$keyword)->paginate(20);
|
|
|
|
- $data3 = BaseSettingsModel::where('category','sign')->where('value','like',$keyword)->paginate(20);
|
|
|
|
|
|
+ orWhere('sign','like',$keyword)->get();
|
|
|
|
+ $data3 = BaseSettingsModel::where('category','sign')->where('value','like',$keyword)->get();
|
|
if (empty($request->keyword)) {
|
|
if (empty($request->keyword)) {
|
|
// 历史搜索
|
|
// 历史搜索
|
|
- $data1 = $user->search()->orderBy('id','desc')->limit(10)->paginate(20);
|
|
|
|
|
|
+ $data1 = $user->search()->orderBy('id','desc')->limit(10)->get();
|
|
// 热门搜索
|
|
// 热门搜索
|
|
- $data2 = SearchInfoModel::paginate(20);
|
|
|
|
|
|
+ $data2 = SearchInfoModel::get();
|
|
$arr = [];
|
|
$arr = [];
|
|
foreach ($data2 as $k => $v) {
|
|
foreach ($data2 as $k => $v) {
|
|
if (count($arr) == 8) {
|
|
if (count($arr) == 8) {
|
|
@@ -182,7 +284,8 @@ class IndexController extends Controller
|
|
arsort($arr);
|
|
arsort($arr);
|
|
return $this->api(compact('arr','data1'));
|
|
return $this->api(compact('arr','data1'));
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+// 写入搜索记录
|
|
|
|
+ $this->insertSearchTable($user->id,$request->keyword);
|
|
return $this->api(compact('data1','data2','data3'));
|
|
return $this->api(compact('data1','data2','data3'));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -212,12 +315,14 @@ class IndexController extends Controller
|
|
*/
|
|
*/
|
|
public function userSearch(Request $request)
|
|
public function userSearch(Request $request)
|
|
{
|
|
{
|
|
|
|
+ $user = $this->getUser();
|
|
if (empty($request->keyword)) {
|
|
if (empty($request->keyword)) {
|
|
return $this->api('');
|
|
return $this->api('');
|
|
}
|
|
}
|
|
$keyword ='%'.$request->keyword.'%';
|
|
$keyword ='%'.$request->keyword.'%';
|
|
- $data1 = UserInfoModel::where('nickname','like',$keyword)->paginate(20);
|
|
|
|
- return $this->api(compact('data1'));
|
|
|
|
|
|
+ $data1 = UserInfoModel::where('nickname','like',$keyword)->get();
|
|
|
|
+ $this->insertSearchTable($user->id,$request->keyword);
|
|
|
|
+ return $this->api(compact('data1'));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -252,16 +357,18 @@ class IndexController extends Controller
|
|
*/
|
|
*/
|
|
public function dreamSearch(Request $request)
|
|
public function dreamSearch(Request $request)
|
|
{
|
|
{
|
|
|
|
+ $user = $this->getUser();
|
|
if (empty($request->keyword)) {
|
|
if (empty($request->keyword)) {
|
|
return $this->api('');
|
|
return $this->api('');
|
|
}
|
|
}
|
|
$keyword ='%'.$request->keyword.'%';
|
|
$keyword ='%'.$request->keyword.'%';
|
|
$data = DreamInfoModel::where('dream','like',$keyword)->
|
|
$data = DreamInfoModel::where('dream','like',$keyword)->
|
|
- orWhere('dream','like',$keyword)->paginate(20);
|
|
|
|
|
|
+ orWhere('sign','like',$keyword)->get();
|
|
foreach ($data as $k => $value) {
|
|
foreach ($data as $k => $value) {
|
|
$value->user_pic = $value->dreamFindUser;
|
|
$value->user_pic = $value->dreamFindUser;
|
|
$value->dream_img = $value->dreamImgsFirst->pic;
|
|
$value->dream_img = $value->dreamImgsFirst->pic;
|
|
}
|
|
}
|
|
|
|
+ $this->insertSearchTable($user->id,$request->keyword);
|
|
return $this->api(compact('data'));
|
|
return $this->api(compact('data'));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -269,7 +376,7 @@ class IndexController extends Controller
|
|
public function getBanner()
|
|
public function getBanner()
|
|
{
|
|
{
|
|
$banner = BaseSettingsModel::where(['category' => 'banner'])->where(['status' => '1'])
|
|
$banner = BaseSettingsModel::where(['category' => 'banner'])->where(['status' => '1'])
|
|
- ->orderBy('sort')->limit('3')->get()->toArray();
|
|
|
|
|
|
+ ->orderBy('sort')->get()->toArray();
|
|
return $banner;
|
|
return $banner;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -279,14 +386,14 @@ class IndexController extends Controller
|
|
foreach ($dreams as $k => $dream) {
|
|
foreach ($dreams as $k => $dream) {
|
|
$dream->dream_user = $dream->dreamUser;
|
|
$dream->dream_user = $dream->dreamUser;
|
|
// 计算被关注总人数
|
|
// 计算被关注总人数
|
|
- $dream->care_num = 0;
|
|
|
|
- $user = UserDream::where('dream_id',$dream->id)->first();
|
|
|
|
- if($user){
|
|
|
|
- $user_id = $user->user_id;
|
|
|
|
- $data = UserCareUser::where('other_user_id',$user_id)->paginate(20);
|
|
|
|
- $dream->care_num = count($data);
|
|
|
|
- }
|
|
|
|
- $dream->dream_img = $dream->dreamImgsFirst?$dream->dreamImgsFirst->pic:'';
|
|
|
|
|
|
+ $user_id = $dream->user_id;
|
|
|
|
+ $data = UserCareDream::where('dream_id',$dream->id)->get();
|
|
|
|
+ $dream->care_num = count($data);
|
|
|
|
+ $dream->dream_imgs_first = $dream->dreamImgsFirst?$dream->dreamImgsFirst->pic:'';
|
|
|
|
+// 梦想详情 detailed 图片 ,评论 ,回复
|
|
|
|
+ $arr = [] ;
|
|
|
|
+ $arr['dream_imgs'] = $dream->dreamImgs;
|
|
|
|
+ $dream->dream_detailed = $arr;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 查看关注用户的最新动态
|
|
// 查看关注用户的最新动态
|
|
@@ -302,42 +409,57 @@ class IndexController extends Controller
|
|
*{
|
|
*{
|
|
* "status": true,
|
|
* "status": true,
|
|
* "status_code": 0,
|
|
* "status_code": 0,
|
|
- * "message": "",
|
|
|
|
- * "data": [
|
|
|
|
- * {
|
|
|
|
- * "dream": "1的梦想",
|
|
|
|
- * "about": "介绍",
|
|
|
|
- * "video": "",
|
|
|
|
- * "time": 0,
|
|
|
|
- * "status": 0,
|
|
|
|
- * "updated_at": null,
|
|
|
|
- * "dream_imgs": [
|
|
|
|
- * {
|
|
|
|
- * "title": "1", 梦想图片介绍
|
|
|
|
- * "pic": "111", 梦想图片
|
|
|
|
- * },
|
|
|
|
- * ],
|
|
|
|
- * "comments": [
|
|
|
|
- * {
|
|
|
|
- * "user_id": 2,
|
|
|
|
- * "level": 0,
|
|
|
|
- * "content": "评论内容", 评论内容
|
|
|
|
- * "updated_at": null,
|
|
|
|
- * "pic": "", 评论者头像
|
|
|
|
- * "replay": [
|
|
|
|
- * {
|
|
|
|
- * "level": 0,
|
|
|
|
- * "content": "回复内容", 回复内容
|
|
|
|
- * "updated_at": null,
|
|
|
|
- * "pic": "" 回复者头像
|
|
|
|
- * }
|
|
|
|
- * ]
|
|
|
|
- * }
|
|
|
|
- * ],
|
|
|
|
- * }
|
|
|
|
- * ]
|
|
|
|
- * }
|
|
|
|
- * ]
|
|
|
|
|
|
+ * "message": "",
|
|
|
|
+ * "data": {
|
|
|
|
+ * "all_interaction": [ 互动
|
|
|
|
+ * {
|
|
|
|
+ * "id": 7,
|
|
|
|
+ * "dream_id": 2,
|
|
|
|
+ * "title": "梦想动态有力来了",
|
|
|
|
+ * "pic1": "http\"//www.baidu.com",
|
|
|
|
+ * "pic2": "",
|
|
|
|
+ * "pic3": "",
|
|
|
|
+ * "pic4": "",
|
|
|
|
+ * "pic5": "",
|
|
|
|
+ * "pic6": "",
|
|
|
|
+ * "pic7": "",
|
|
|
|
+ * "pic8": "",
|
|
|
|
+ * "pic9": "",
|
|
|
|
+ * "status": 1,
|
|
|
|
+ * "created_at": "2017-06-22 21:09:18",
|
|
|
|
+ * "updated_at": "2017-06-22 21:09:18",
|
|
|
|
+ * "deleted_at": null,
|
|
|
|
+ * "user_id": 2,
|
|
|
|
+ * "time": 720000, 倒计时
|
|
|
|
+ * "comments": [ 评论
|
|
|
|
+ * {
|
|
|
|
+ * "interaction_id": 7,
|
|
|
|
+ * "user_id": 1,
|
|
|
|
+ * "level": 0,
|
|
|
|
+ * "content": "不错的梦想",
|
|
|
|
+ * "updated_at": null,
|
|
|
|
+ * "pic": "http://www.wsfjq.com/photos/bd119684755.jpg",
|
|
|
|
+ * "replay": [ 回复
|
|
|
|
+ * {
|
|
|
|
+ * "user_id": 1,
|
|
|
|
+ * "level": 0,
|
|
|
|
+ * "content": "我也觉得不错",
|
|
|
|
+ * "updated_at": null,
|
|
|
|
+ * "pic": "http://www.wsfjq.com/photos/bd119684755.jpg"
|
|
|
|
+ * },
|
|
|
|
+ * {
|
|
|
|
+ * "user_id": 6,
|
|
|
|
+ * "level": 0,
|
|
|
|
+ * "content": "祝你梦想成真",
|
|
|
|
+ * "updated_at": null,
|
|
|
|
+ * "pic": "http://www.wsfjq.com/photos/bd119684755.jpg"
|
|
|
|
+ * }
|
|
|
|
+ * ]
|
|
|
|
+ * }
|
|
|
|
+ * ]
|
|
|
|
+ * },
|
|
|
|
+ * ]
|
|
|
|
+ * }
|
|
*}
|
|
*}
|
|
* @apiErrorExample {json} Error-Response:
|
|
* @apiErrorExample {json} Error-Response:
|
|
* HTTP/1.1 400 Bad Request
|
|
* HTTP/1.1 400 Bad Request
|
|
@@ -348,19 +470,37 @@ class IndexController extends Controller
|
|
$user = $this->getUser();
|
|
$user = $this->getUser();
|
|
$other_id = $request->id;
|
|
$other_id = $request->id;
|
|
if (empty($other_id)) return $this->error(ErrorCode::MEMBER_NOT_EXIST);
|
|
if (empty($other_id)) return $this->error(ErrorCode::MEMBER_NOT_EXIST);
|
|
- UserCareUser::where('user_id',$user->id)->where('other_user_id',$other_id)->update(['dream_num'=>0]);
|
|
|
|
- $data = UserInfoModel::find($other_id)->UserDream;
|
|
|
|
- foreach ($data as $item) {
|
|
|
|
- $item->dream_imgs = $item->dreamImgs ;
|
|
|
|
- $item->comments = $item->DreamInfo;
|
|
|
|
- foreach ( $item->comments as $k => $v){
|
|
|
|
- $v->pic = UserInfoModel::find($v->user_id)->pic;
|
|
|
|
|
|
+ UserCareDream::where('user_id',$user->id)->where('dream_user_id',$other_id)->update(['interaction_number'=>0]);
|
|
|
|
+ $data = UserInfoModel::where('id',$other_id)->with(['allInteraction'=>function ($query){
|
|
|
|
+ $query->orderBy('id','desc');
|
|
|
|
+ }])->first();
|
|
|
|
+// $data = UserInfoModel::find($other_id)->allInteraction;
|
|
|
|
+// dd($data) ;
|
|
|
|
+// dd($data->allInteraction);
|
|
|
|
+ foreach ($data->allInteraction as $item) {
|
|
|
|
+ $item->time = DreamInfoModel::find($item->dream_id)->time;
|
|
|
|
+ $item->comments = $item->comments;
|
|
|
|
+ foreach ($item->comments as $k => $v) {
|
|
|
|
+ $v->pic = UserInfoModel::find($v->user_id)->pic;
|
|
$v->replay = $v->replay;
|
|
$v->replay = $v->replay;
|
|
- foreach ($v->replay as $k1 => $v1){
|
|
|
|
- $v1->pic = UserInfoModel::find($v1->user_id)->pic;
|
|
|
|
|
|
+ foreach ($v->replay as $k1 => $v1) {
|
|
|
|
+ $v1->pic = UserInfoModel::find($v1->user_id)->pic;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return $this->api($data);
|
|
return $this->api($data);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public function insertSearchTable($id,$keyword)
|
|
|
|
+ {
|
|
|
|
+ $info = SearchInfoModel::where('user_id',$id)->
|
|
|
|
+ where('search',trim($keyword))->first();
|
|
|
|
+ if (count($info) == 0) {
|
|
|
|
+ SearchInfoModel::create(['user_id'=>$id,'search'=>trim($keyword),'times'=>1]);
|
|
|
|
+ }else{
|
|
|
|
+ $info->times += 1;
|
|
|
|
+ $info->save();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|