/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $item = Comment::find($id); if ($item != null) { $answer = AnswerComment::where('comment_id', '=', $id)->get(); return view('comment.show', compact('item', 'answer')); } return Redirect::to(URL::to('datatables', ['comentarios', 'see']))->with('error', 'id-nn'); }
public function index() { $date1 = date('Y/m/d ') . ' 00:00:00'; $date2 = date('Y/m/d ') . ' 23:59:59'; $idComments = Comment::all()->lists('id'); $comment5 = Comment::select()->orderBy('created_at', 'desc')->limit(5)->get(); $commentsToday = Comment::select()->where('type', '<>', 'Error')->whereBetween('created_at', [$date1, $date2])->get(); $commentWithAnswer = Comment::select()->where('type', '=', 'Error')->get(); $commentWithAnswerToday = AnswerComment::select()->whereBetween('created_at', [$date1, $date2])->get(); $totalComments = sizeof($idComments); $totalcWa = sizeof($commentWithAnswer); $totalcWNa = $totalComments - $totalcWa; $totalCommentsToday = sizeof($commentsToday); $totalCommentsWithAnswerToday = sizeof($commentWithAnswerToday); return view('index', compact('totalcWa', 'totalcWNa', 'comment5', 'totalCommentsToday', 'totalCommentsWithAnswerToday')); }