BeanDetailController.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 starHome(Request $request)
  37. {
  38. $star_home = $this->beanRepository->starHome($request->all());
  39. if ($star_home){
  40. return $this->jsonSuccess($star_home);
  41. }else{
  42. return $this->jsonSuccess();
  43. }
  44. }
  45. }