HomeController.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Services\HomeService;
  4. use http\Env\Response;
  5. use Illuminate\Http\Request;
  6. class HomeController extends Controller
  7. {
  8. public $homeService;
  9. public function __construct()
  10. {
  11. $this->homeService = new HomeService();
  12. }
  13. /**
  14. * 获取位置信息
  15. */
  16. public function get_location(Request $request){
  17. }
  18. /**
  19. * 返回首页信息
  20. * @param Request $request
  21. * @return \Illuminate\Http\JsonResponse|void
  22. */
  23. public function home(Request $request){
  24. try {
  25. $param['keyword'] = $request->post('keyword','');//关键词,昵称,标签
  26. $param['nearby'] = $request->post('nearby',1);//附近
  27. $param['online'] = $request->post('online',1);//在线
  28. $param['new'] = $request->post('new',1);//新人
  29. $res = $this->homeService->get_list($param);
  30. }catch (\Exception $exception){
  31. return $this->response->errorForbidden($exception->getMessage());
  32. }
  33. return response()->json($res);
  34. }
  35. }