12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace App\Http\Controllers\V1;
- use App\Repositories\BeanRepository;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Validator;
- use Illuminate\Validation\Rule;
- /**
- * Created by PhpStorm.
- * User: durong
- * Date: 2019/6/19
- * Time: 下午12:25
- */
- class BeanDetailController extends Controller
- {
- public function __construct(BeanRepository $beanRepository)
- {
- $this->beanRepository = $beanRepository;
- }
- //排行榜
- public function rankingList(Request $request)
- {
- $data = $request->all();
- $validator = Validator::make($data, [
- 'type' => ['required',Rule::in([0,1, 2])],
- ]);
- if ($validator->fails()) {
- return $this->jsonError($validator->errors()->first());
- }
- $top_most = $this->beanRepository->rankingList($data);
- if ($top_most){
- return success(['list'=>$top_most]);
- }else{
- return success(['list' => []]);
- }
- }
- //分享/邀请首页
- public function starDetail(Request $request)
- {
- $validator = Validator::make($request->all(), [
- 'invite_code' => 'required',
- ]);
- if ($validator->fails()) {
- return $this->jsonError($validator->errors()->first());
- }
- $star_detail = $this->beanRepository->starDetail($request->all());
- if ($star_detail){
- return $this->jsonSuccess($star_detail);
- }else{
- return $this->jsonSuccess();
- }
- }
- //星球首页
- public function starHome(Request $request)
- {
- $star_home = $this->beanRepository->starHome($request->all());
- if ($star_home){
- return $this->jsonSuccess($star_home);
- }else{
- return $this->jsonSuccess();
- }
- }
- }
|