IndexController.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. public function hot(Request $request)
  34. {
  35. $user = $this->getUser();
  36. //获取轮播图
  37. $banner = BaseSettingsModel::where(['category' => 'banner'])->where(['status' => '1'])
  38. ->orderBy('sort')->limit('3')->get()->toArray();
  39. // 关注的用户
  40. $other_user = $user->UserCareUser;
  41. // 获取其他用户信息 及梦想
  42. $dreams = DreamInfoModel::orderBy('created_at')->get();
  43. foreach ($dreams as $k => $dream) {
  44. $dream->dream_find_user = $dream->dreamFindUser;
  45. }
  46. return $this->api(compact('banner','other_user','dreams'));
  47. }
  48. }