BeanDetailController.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace App\Http\Controllers\V1;
  3. use App\Repositories\BeanRepository;
  4. use Illuminate\Http\Request;
  5. use Illuminate\Support\Facades\Validator;
  6. use Illuminate\Validation\Rule;
  7. /**
  8. * Created by PhpStorm.
  9. * User: durong
  10. * Date: 2019/6/19
  11. * Time: 下午12:25
  12. */
  13. class BeanDetailController extends Controller
  14. {
  15. public function __construct(BeanRepository $beanRepository)
  16. {
  17. $this->beanRepository = $beanRepository;
  18. }
  19. //排行榜
  20. public function rankingList(Request $request)
  21. {
  22. $data = $request->all();
  23. $validator = Validator::make($data, [
  24. 'type' => ['required',Rule::in([0,1, 2])],
  25. ]);
  26. if ($validator->fails()) {
  27. return $this->jsonError($validator->errors()->first());
  28. }
  29. $top_most = $this->beanRepository->rankingList($data);
  30. if ($top_most){
  31. return success(['list'=>$top_most]);
  32. }else{
  33. return success(['list' => []]);
  34. }
  35. }
  36. //分享/邀请首页
  37. public function starDetail(Request $request)
  38. {
  39. $validator = Validator::make($request->all(), [
  40. 'invite_code' => 'required',
  41. ]);
  42. if ($validator->fails()) {
  43. return $this->jsonError($validator->errors()->first());
  44. }
  45. $star_detail = $this->beanRepository->starDetail($request->all());
  46. if ($star_detail){
  47. return $this->jsonSuccess($star_detail);
  48. }else{
  49. return $this->jsonSuccess();
  50. }
  51. }
  52. //星球首页
  53. public function starHome(Request $request)
  54. {
  55. $star_home = $this->beanRepository->starHome($request->all());
  56. if ($star_home){
  57. return $this->jsonSuccess($star_home);
  58. }else{
  59. return $this->jsonSuccess();
  60. }
  61. }
  62. }