1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- namespace App\Http\Controllers\Api\V1\Mentality;
- use Illuminate\Http\Request;
- use App\Http\Controllers\Api\V1\BaseController;
- use App\Facades\ScaleFacade;
- class ScaleController extends BaseController
- {
- /**
- * Display a listing of the resource.
- *
- * @return \Illuminate\Http\Response
- */
- public function index()
- {
- $commentTag = request('comment_tag');
- if ($commentTag){
- $commentTag = json_decode($commentTag);
- }
- $conditions = [
- 'category_id' => request('category_id'),
- 'search' => request('search'),
- 'comment_tag' => $commentTag
- ];
- // var_dump($conditions);exit;
- $fields = ['*'];
- switch (request('sort')) {
- case 1: // 最新上架
- $sort = '`id` desc';
- break;
- case 2: // 最受欢迎
- $sort = '`number_of_test` desc';
- break;
- default:
- $sort = '`rank` desc, `id` desc';
- }
- $page = request('page', 1);
- $limit = request('limit', 20);
- return ScaleFacade::getList($conditions, $fields, $sort, $page, $limit);
- }
- /**
- * Store a newly created resource in storage.
- *
- * @param \Illuminate\Http\Request $request
- * @return \Illuminate\Http\Response
- */
- public function store(Request $request)
- {
- //
- }
- /**
- * Display the specified resource.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function show($id)
- {
- $conditions = ['id' => $id, 'uid'=>$this->auth()];
- $fields = ['*'];
- return ScaleFacade::findBy($conditions, $fields);
- }
- /**
- * Update the specified resource in storage.
- *
- * @param \Illuminate\Http\Request $request
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function update(Request $request, $id)
- {
- //
- }
- /**
- * Remove the specified resource from storage.
- *
- * @param int $id
- * @return \Illuminate\Http\Response
- */
- public function destroy($id)
- {
- //
- }
- public function startTest(Request $request){
- // return ScaleFacade::createThirdScale(0, 100, '异性');
- return ScaleFacade::startTest($this->auth(), intval($request->scale_id));
- }
- }
|