Ejemplo n.º 1
0
 public function nextSequenceQuestion($question_id, $phase_id)
 {
     $question = Question::find($question_id);
     $next_sequence_question = Question::where('sequence_number', '>', $question->sequence_number)->where('phase_id', '=', $question->phase_id)->orderBy('sequence_number', 'asc')->first();
     if ($next_sequence_question) {
         return $next_sequence_question;
     }
     return FALSE;
 }
 public function resolveQuestion()
 {
     $request = Request::capture();
     $token = $request->input('token');
     $answerId = $request->input('answerId');
     if ($answerId == null) {
         return Utility::response_format(Utility::RESPONSE_CODE_Error, '', 'answerId不能为空');
     }
     $userId = AuthController::getUserIdByToken($token);
     if ($userId == null) {
         return Utility::response_format(Utility::RESPONSE_CODE_AUTH_ERROR, '', '认证失败');
     }
     $answer = Answer::where('id', $answerId)->first();
     $question = Question::where('id', $answer->question_id)->first();
     if ($question->user_id != $userId) {
         return Utility::response_format(Utility::RESPONSE_CODE_Error, '', '不是问题所属用户');
     }
     $isResolved = $answer->is_resolved;
     if ($isResolved) {
         return Utility::response_format(Utility::RESPONSE_CODE_Error, '', '问题已解决');
     }
     $answer->is_resolved = 1;
     $answer->save();
     return Utility::response_format(Utility::RESPONSE_CODE_SUCCESS, '', '请求成功');
 }
Ejemplo n.º 3
0
 public function getChildQuestions($question_id)
 {
     return Question::where('parent_id', '=', $question_id)->orderBy('sequence_number')->get();
 }