with('user')->orderBy('id'); $is_submit = $request->input('is_submit'); if (is_numeric($is_submit)) { $questions = $questions->where('is_submit', $is_submit); } $status = $request->input('status', 0); if ($status != 2) { $questions = $questions->where('status', $status); } $questions = $questions->paginate(); return $this->success('ok', $questions); } /** * 问题详情 */ public function question(Request $request, SoulQuestion $soul_question) { $soul_question->user; $answers = $soul_question->answers(); $type = $request->input('type'); if ($type) { $answers = $answers->where('type', $type); } $answers = $answers->with('user')->paginate(); $soul_question->answers = $answers; return $this->success('ok', $soul_question); } /** * 审核问题 */ public function checkQuestion(Request $request, SoulQuestion $soul_question) { $status = $request->input('status', 1); $soul_question->status = $status; $soul_question->save(); return $this->success('ok'); } /** * 删除问题 */ public function deleteQuestion(Request $request, SoulQuestion $soul_question) { $soul_question->delete(); return $this->success('ok'); } /** * 删除答案 */ public function deleteQuestionAnswer(Request $request, SoulAnswer $soul_answer) { $soul_answer->delete(); return $this->success('ok'); } }