Show separate post

  1. Go to PostController@show
  2. Add:
$post = Post::find($id); //no need to create new instance of Post model it is static

//return view('posts.show')->with('post', $post);
return view('posts.show')->withPost($post);

Add the array variable $post to the posts.show view (views>posts>show.blade.php)

here we have used Eloquent

Show all posts

Add the following to the PostController->index()

$posts = Post::all();
return view('posts.index')->withPosts($posts);

results matching ""

    No results matching ""