/** * Display the specified resource. * * @param int $id * @return Response */ public function show(News $news) { $news->increment('dibaca'); $comments = Comments::orderBy('created_at', 'DESC')->get()->where('news_id', $news->id); $sidebar = $news->orderBy('dibaca', 'DESC')->limit(5)->get(); $otherposts = News::orderBy('created_at', 'DESC')->where('kategori_id', $news->kategori_id)->limit(3)->get(); return view('sowindows.show', compact(['news', 'otherposts', 'comments', 'sidebar'])); }
public function index(Request $request) { $comments = Comments::orderBy('id', 'desc')->paginate(5); $result = []; foreach ($comments as $row) { $result[] = ['id' => (int) $row->id, 'name' => ucwords($row->name), 'city' => ucwords($row->city), 'comment' => $row->comment]; } return response()->json($result)->setCallback($request->input('callback')); }
public function index(Request $request) { if (!($count = $this->redis->get(COUNTER_KEY))) { $count = Votes::count(); $this->redis->set(COUNTER_KEY, $count); } if ($count > 999 && $count <= 999999) { $kFormat = number_format($count / 1000, 1, '.', ' ') . ' K'; } elseif ($count > 999999) { $kFormat = number_format($count / 1000000, 1, '.', ' ') . ' M'; } else { $kFormat = $count; } $total = str_pad($count, 6, 0, STR_PAD_LEFT); $exist = $request->session()->get('voted'); $comments = Comments::orderBy('id', 'desc')->limit(5)->get(); $commentCount = Comments::count(); return view('home', ['total' => $total, 'count' => $count, 'exist' => $exist, 'kFormat' => $kFormat, 'comments' => $comments, 'commentCount' => $commentCount]); }
public function listComment(Request $request) { $comments = Comments::orderBy('id', 'desc')->get(); return view('comments/index', ['comment' => $comments, 'type' => 'list']); }