Esempio n. 1
0
 /**
  * Show one blog post
  * GET
  *
  * @param int $id
  * @param string $title
  * @return Response
  */
 public function showBlog($id, $title)
 {
     $blog = BlogManager::find($id);
     $nextBlog = BlogManager::find($blog->id + 1);
     $prevBlog = BlogManager::find($blog->id - 1);
     $comments = BlogCommentManager::join('accounts', 'accounts.guid', '=', 'cms_blogs_comments.author')->where('blog_id', $blog->id)->orderBy('date', 'desc')->paginate(10);
     $countComments = BlogCommentManager::where('blog_id', $blog->id)->count();
     return view('home.blog', compact('blog', 'comments', 'nextBlog', 'prevBlog', 'countComments'));
 }
 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 removeCmt($id)
 {
     return Comment::where('id', $id)->delete();
 }
 public function singleAction($id)
 {
     if ($entry = Entry::findOrFail($id)) {
         if ($postData = $this->getPostData()) {
             $postData['entry_id'] = $id;
             Comment::create($postData);
             return $this->redirect('singleEntry', array('id' => $id));
         }
         $entry['username'] = User::where('id', strval($entry['user_id']))->first()['name'];
         $data['entry'] = $entry;
         $data['comments'] = Comment::where('entry_id', $id)->get();
     } else {
         $data['error'] = 'Không tìm thấy bài viết';
     }
     return $this->render('entry/single.html.twig', $data);
 }
Esempio n. 5
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  * Trả về list các comments có id thuộc id của bài viết
  */
 public function show($id)
 {
     return Response::json(Comment::where('news_id', $id)->orderBy('id', 'desc')->get());
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $comment = Comment::where('page_id', $id)->delete();
     $page = Page::find($id)->delete();
     return Redirect::to('admin');
 }