IndexController.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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/home/hot 热门(hot)
  12. * @apiSuccessExample {json} Success-Response:
  13. * HTTP/1.1 200 OK
  14. * {
  15. * "state": true,
  16. * "code": 0,
  17. * "message": "",
  18. * "data": {
  19. * "verify_code": "1234"//该值调试时使用,sms调通后取消
  20. * }
  21. * }
  22. * @apiErrorExample {json} Error-Response:
  23. * HTTP/1.1 400 Bad Request
  24. * {
  25. * "state": false,
  26. * "code": 1000,
  27. * "message": "传入参数不正确",
  28. * "data": null or []
  29. * }
  30. * 可能出现的错误代码:
  31. * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
  32. */
  33. /**
  34. * @api {get} /api/home/hot 热门(hot)
  35. * @apiDescription 登陆(hot)
  36. * @apiGroup Auth
  37. * @apiPermission none
  38. * @apiVersion 0.1.0
  39. * @apiParam {string} phone 手机号码
  40. * @apiSuccessExample {json} Success-Response:
  41. * HTTP/1.1 200 OK
  42. * {
  43. * "state": true,
  44. * "code": 0,
  45. * "message": "",
  46. * "data": {
  47. * "verify_code": "1234"//该值调试时使用,sms调通后取消
  48. * }
  49. * }
  50. * @apiErrorExample {json} Error-Response:
  51. * HTTP/1.1 400 Bad Request
  52. * {
  53. * "state": false,
  54. * "code": 1000,
  55. * "message": "传入参数不正确",
  56. * "data": null or []
  57. * }
  58. * 可能出现的错误代码:
  59. * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
  60. */
  61. public function hot(Request $request)
  62. {
  63. $user = $this->getUser();
  64. //获取轮播图
  65. $banner = BaseSettingsModel::where(['category' => 'banner'])->where(['status' => '1'])
  66. ->orderBy('sort')->limit('3')->get()->toArray();
  67. // 关注的用户
  68. $other_user = $user->UserCareUser;
  69. // 获取其他用户信息 及梦想
  70. $dreams = DreamInfoModel::orderBy('created_at')->get();
  71. foreach ($dreams as $k => $dream) {
  72. $dream->dream_find_user = $dream->dreamFindUser;
  73. }
  74. return $this->api(compact('banner','other_user','dreams'));
  75. }
  76. }