public function getAnswerDetail()
 {
     $request = Request::capture();
     $token = $request->input('token');
     $answerId = $request->input('answerId');
     $userId = AuthController::getUserIdByToken($token);
     if ($userId == null) {
         return Utility::response_format(Utility::RESPONSE_CODE_AUTH_ERROR, '', '认证失败');
     }
     if ($answerId == null) {
         return Utility::response_format(Utility::RESPONSE_CODE_Error, '', 'answerId不能为空');
     }
     $answer = Answer::select('id', 'answer_content', 'answer_time', 'question_id', 'user_id', 'is_resolved')->where('id', $answerId)->first()->toArray();
     //        print_r($question);
     // 个人信息
     $userInfo = UserInfo::select('user_name', 'head_pic')->where('user_id', $answer['user_id'])->first()->toArray();
     $answer = array_merge($answer, $userInfo);
     // 图片
     $picIds = AnswerPictures::select('pic_id')->where('answer_id', $answer['id'])->get()->toArray();
     $pics = Picture::whereIn('id', $picIds)->get()->toArray();
     $answer = array_merge($answer, ['image' => $pics]);
     // 评论数
     $comments = Comment::where('answer_id', $answer['id'])->count();
     $answer = array_merge($answer, ['commentNumber' => $comments]);
     // 赞数
     $upCount = AnswerUp::where('answer_id', $answer['id'])->count();
     $answer = array_merge($answer, ['upNumber' => $upCount]);
     return Utility::response_format(Utility::RESPONSE_CODE_SUCCESS, $answer, '请求成功');
 }
 public function addUserTags()
 {
     $request = Request::capture();
     $token = $request->input('token');
     $tags = $request->input('tags');
     if ($tags == null) {
         return Utility::response_format(Utility::RESPONSE_CODE_Error, '', '标签不能为空');
     }
     $userId = AuthController::getUserIdByToken($token);
     if ($userId == null) {
         return Utility::response_format(Utility::RESPONSE_CODE_AUTH_ERROR, '', '认证失败');
     }
     DB::beginTransaction();
     try {
         $array = explode(',', $tags);
         $result = UserTags::where('user_id', $userId)->delete();
         foreach ($array as $tag) {
             $result = UserTags::create(['user_id' => $userId, 'tag_id' => $tag]);
         }
         DB::commit();
         return Utility::response_format(Utility::RESPONSE_CODE_SUCCESS, '', '添加成功');
     } catch (Exception $e) {
         DB::rollBack();
         return Utility::response_format(Utility::RESPONSE_CODE_DB_ERROR, '', $e->getMessage());
     }
 }