/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // this id will be article id, be careful $images = HomeImage::where('article_id', '=', $id)->get(); $categories = Category::all(); $article = Article::findOrFail($id); $articlesNumber = CategoriesController::getCategoryArticle(); /** * Need refactory */ $comments = DB::table('comments')->join('users', 'users.id', '=', 'comments.user_id')->where('article_id', '=', $id)->orderBy('comments.created_at', 'desc')->select('comments.*', 'users.name')->get(); // dd($images); return view('articles.show', compact('categories', 'article', 'comments', 'articlesNumber', 'images')); }