Show separate post
- Go to PostController@show
- 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 theposts.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);