/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $posts = Post::orderBy('created_at', 'desc')->paginate(6, ['*'], 'p'); $comments = Comment::all(); $data = ['comments' => $comments, 'posts' => $posts]; return view('posts.index', $data); }