BeanDetailController.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. $validator = Validator::make($request->all(), [
  23. 'type' => ['required',Rule::in([0,1, 2])],
  24. ]);
  25. if ($validator->fails()) {
  26. return $this->jsonError($validator->errors()->first());
  27. }
  28. $top_most = $this->beanRepository->rankingList($request->all());
  29. if ($top_most){
  30. return $this->jsonSuccess($top_most);
  31. }else{
  32. return $this->jsonSuccess();
  33. }
  34. }
  35. //分享/邀请首页
  36. public function starDetail(Request $request)
  37. {
  38. $validator = Validator::make($request->all(), [
  39. 'invite_code' => 'required',
  40. ]);
  41. if ($validator->fails()) {
  42. return $this->jsonError($validator->errors()->first());
  43. }
  44. $star_detail = $this->beanRepository->starDetail($request->all());
  45. if ($star_detail){
  46. return $this->jsonSuccess($star_detail);
  47. }else{
  48. return $this->jsonSuccess();
  49. }
  50. }
  51. //星球首页
  52. public function starHome(Request $request)
  53. {
  54. $star_home = $this->beanRepository->starHome($request->all());
  55. if ($star_home){
  56. return $this->jsonSuccess($star_home);
  57. }else{
  58. return $this->jsonSuccess();
  59. }
  60. }
  61. }