|
@@ -331,6 +331,7 @@ class MyController extends Controller
|
|
* @apiDescription 我的收藏
|
|
* @apiDescription 我的收藏
|
|
* @apiGroup My
|
|
* @apiGroup My
|
|
* @apiPermission Passport
|
|
* @apiPermission Passport
|
|
|
|
+ * @apiParam {string} keyword 关键字可选
|
|
* @apiVersion 0.1.0
|
|
* @apiVersion 0.1.0
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* HTTP/1.1 200 OK
|
|
* HTTP/1.1 200 OK
|
|
@@ -362,62 +363,7 @@ class MyController extends Controller
|
|
* }
|
|
* }
|
|
* }
|
|
* }
|
|
*}
|
|
*}
|
|
- * @apiErrorExample {json} Error-Response:
|
|
|
|
- * HTTP/1.1 400 Bad Request
|
|
|
|
- */
|
|
|
|
- public function collection()
|
|
|
|
- {
|
|
|
|
- $user = $this->getUser();
|
|
|
|
- $dreams = $user->collection;
|
|
|
|
- $users = [];
|
|
|
|
- foreach ($dreams as $item) {
|
|
|
|
- if ($item->pivot->interaction_number > 0) {
|
|
|
|
- $user_info = UserInfoModel::find($item->pivot->dream_user_id);
|
|
|
|
- $avatar = $user_info ? $user_info->avatar : '';
|
|
|
|
- if (!array_key_exists($item->pivot->dream_user_id,$users)) {
|
|
|
|
- $users[$item->pivot->dream_user_id] = $avatar;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- $item->img;
|
|
|
|
- }
|
|
|
|
- return $this->api(compact('dreams','users'));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * @api {get} /api/my/setting 设置
|
|
|
|
- * @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": {
|
|
|
|
- * "key": "2511789", 电话
|
|
|
|
- * "value": "关于喵喵介绍" 关于喵喵
|
|
|
|
- * }
|
|
|
|
- *}
|
|
|
|
- * @apiErrorExample {json} Error-Response:
|
|
|
|
- * HTTP/1.1 400 Bad Request
|
|
|
|
- */
|
|
|
|
- public function setting()
|
|
|
|
- {
|
|
|
|
- $data = BaseSettingsModel::where('category','miaomiao')->select('key','value')->first();
|
|
|
|
- return $this->api($data);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * @api {get} /api/my/search_collection 梦想搜索
|
|
|
|
- * @apiDescription 梦想搜索
|
|
|
|
- * @apiGroup My
|
|
|
|
- * @apiPermission none
|
|
|
|
- * @apiVersion 0.1.0
|
|
|
|
- * @apiParam {string} keyword 关键字
|
|
|
|
- * @apiSuccessExample {json} Success-Response:
|
|
|
|
- * HTTP/1.1 200 OK
|
|
|
|
|
|
+ * keyword存在
|
|
{
|
|
{
|
|
"status": true,
|
|
"status": true,
|
|
"status_code": 0,
|
|
"status_code": 0,
|
|
@@ -447,7 +393,7 @@ class MyController extends Controller
|
|
"sign": "梦想达人",
|
|
"sign": "梦想达人",
|
|
"created_at": "2017-06-25 13:10:56",
|
|
"created_at": "2017-06-25 13:10:56",
|
|
"updated_at": "2017-06-28 16:53:39"
|
|
"updated_at": "2017-06-28 16:53:39"
|
|
- "img": {
|
|
|
|
|
|
+ "img": { 图片
|
|
"title": "",
|
|
"title": "",
|
|
"pic": "https://timgsa.baidu.com/timg9&di2f.jpg"
|
|
"pic": "https://timgsa.baidu.com/timg9&di2f.jpg"
|
|
}
|
|
}
|
|
@@ -459,20 +405,62 @@ class MyController extends Controller
|
|
* @apiErrorExample {json} Error-Response:
|
|
* @apiErrorExample {json} Error-Response:
|
|
* HTTP/1.1 400 Bad Request
|
|
* HTTP/1.1 400 Bad Request
|
|
*/
|
|
*/
|
|
- public function searchCollection(Request $request)
|
|
|
|
|
|
+ public function collection(Request $request)
|
|
{
|
|
{
|
|
$user = $this->getUser();
|
|
$user = $this->getUser();
|
|
- $keyword ='%'.$request->keyword.'%';
|
|
|
|
- $data = UserCareDream::where('user_id',$user->id)->
|
|
|
|
- whereHas('dreams',function ($query) use($keyword){
|
|
|
|
- $query->where('end_time','<=',time())->where('name','like',$keyword);
|
|
|
|
- })->with('dreams')->get();
|
|
|
|
- foreach ($data as $item) {
|
|
|
|
- foreach ($item->dreams as $dream) {
|
|
|
|
- $dream->img;
|
|
|
|
- }
|
|
|
|
|
|
+ if ($request->keyword) {
|
|
|
|
+ $keyword ='%'.$request->keyword.'%';
|
|
|
|
+ $data = UserCareDream::where('user_id',$user->id)->
|
|
|
|
+ whereHas('dreams',function ($query) use($keyword){
|
|
|
|
+ $query->where('end_time','>=',time())->where('name','like',$keyword);
|
|
|
|
+ })->with('dreams')->get();
|
|
|
|
+ foreach ($data as $item) {
|
|
|
|
+ foreach ($item->dreams as $dream) {
|
|
|
|
+ $dream->img;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $this->insertSearchTable($user->id,$request->keyword);
|
|
|
|
+ return $this->api($data);
|
|
|
|
+ }else{
|
|
|
|
+ $dreams = $user->collection;
|
|
|
|
+ $users = [];
|
|
|
|
+ foreach ($dreams as $item) {
|
|
|
|
+ if ($item->pivot->interaction_number > 0) {
|
|
|
|
+ $user_info = UserInfoModel::find($item->pivot->dream_user_id);
|
|
|
|
+ $avatar = $user_info ? $user_info->avatar : '';
|
|
|
|
+ if (!array_key_exists($item->pivot->dream_user_id,$users)) {
|
|
|
|
+ $users[$item->pivot->dream_user_id] = $avatar;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $item->img;
|
|
|
|
+ }
|
|
|
|
+ return $this->api(compact('dreams','users'));
|
|
}
|
|
}
|
|
- $this->insertSearchTable($user->id,$request->keyword);
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @api {get} /api/my/setting 设置
|
|
|
|
+ * @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": {
|
|
|
|
+ * "key": "2511789", 电话
|
|
|
|
+ * "value": "关于喵喵介绍" 关于喵喵
|
|
|
|
+ * }
|
|
|
|
+ *}
|
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
|
+ */
|
|
|
|
+ public function setting()
|
|
|
|
+ {
|
|
|
|
+ $data = BaseSettingsModel::where('category','miaomiao')->select('key','value')->first();
|
|
return $this->api($data);
|
|
return $this->api($data);
|
|
}
|
|
}
|
|
|
|
|