/** * Display a listing of the Post. * * @return Response */ public function index() { $posts = Post::all(); return $posts; }
/** * Show the main page. * * @return Response */ public function index() { $posts = Post::all()->sortByDesc('created_at')->toArray(); $data = ['posts' => $posts]; return view('blog.index')->with($data); }