request('category_id'), 'search' => request('search'), 'comment_tag' => $commentTag ]; $fields = ['*']; switch (request('sort')) { case 1: // 最新上架 $sort = '`id` desc'; break; case 2: // 最受欢迎 $sort = '`number_of_studies` desc'; break; default: $sort = '`rank` desc, `id` desc'; } $page = request('page', 1); $limit = request('limit', 20); return MentalityDrillFacade::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 ]; $record = [ 'uid' => $this->auth(), 'column' => BrowseRecord::COLUMN_2, 'object_id' => $id, 'repeat' => 'uid:'.$this->auth().' column:'.BrowseRecord::COLUMN_2.' object_id:'.$id ]; //加入浏览记录 try { BrowseRecordFacade::create($record); } catch (\Exception $e) { } return MentalityDrillFacade::findBy($conditions, ['*']); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // } /** * 播放训练科目 * @param int $id * @return mixed */ public function playSubject(int $id) { $record = [ 'uid' => $this->auth(), 'column' => BrowseRecord::COLUMN_4, 'object_id' => $id, 'repeat' => 'uid:'.$this->auth().' column:'.BrowseRecord::COLUMN_4.' object_id:'.$id ]; //加入浏览记录 try { BrowseRecordFacade::create($record); } catch (\Exception $e) { } return response()->horesp(1000, MentalityDrillsSubject::query()->find($id), "成功"); } /** * 点赞 * @param $id * @return array */ public function thumbsUpNum($id) { return MentalityDrillFacade::thumbsUpNum($id,$this->auth()); } /** * 喜欢 * @param $id * @return array */ public function loveNum($id) { return MentalityDrillFacade::loveNum($id,$this->auth()); } /** * 留言 * @param Request $request * @return array */ public function leaveMessage(Request $request) { $id = $request->get("id",0); $message = $request->get("message",0); return MentalityDrillFacade::leaveMessage($id,$this->auth(),$message); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // } }