IndexController.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace App\Http\Controllers\Api\V1;
  3. use App\Models\BaseSettingsModel;
  4. use App\Models\DreamInfoModel;
  5. use App\Models\UserInfoModel;
  6. use Illuminate\Http\Request;
  7. use App\Services\Base\ErrorCode;
  8. class IndexController extends Controller
  9. {
  10. /**
  11. * @api {get} /api/index/hot 热门(hot)
  12. * @apiDescription 登陆(hot)
  13. * @apiGroup Index
  14. * @apiPermission none
  15. * @apiVersion 0.1.0
  16. * @apiParam {string} phone 手机号码
  17. * @apiSuccessExample {json} Success-Response:
  18. * HTTP/1.1 200 OK
  19. * {
  20. * "state": true,
  21. * "code": 0,
  22. * "message": "",
  23. * "data": {
  24. * "verify_code": "1234"//该值调试时使用,sms调通后取消
  25. * }
  26. * }
  27. * @apiErrorExample {json} Error-Response:
  28. * HTTP/1.1 400 Bad Request
  29. * {
  30. * "state": false,
  31. * "code": 1000,
  32. * "message": "传入参数不正确",
  33. * "data": null or []
  34. * }
  35. * 可能出现的错误代码:
  36. * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
  37. */
  38. public function hot(Request $request)
  39. {
  40. $user = $this->getUser();
  41. //获取轮播图
  42. $banner = BaseSettingsModel::where(['category' => 'banner'])->where(['status' => '1'])
  43. ->orderBy('sort')->limit('3')->get()->toArray();
  44. // 关注的用户
  45. $other_user = $user->UserCareUser;
  46. // 获取其他用户信息 及梦想
  47. $dreams = DreamInfoModel::orderBy('created_at')->get();
  48. foreach ($dreams as $k => $dream) {
  49. $dream->dream_find_user = $dream->dreamFindUser;
  50. }
  51. return $this->api(compact('banner','other_user','dreams'));
  52. }
  53. }