I am new to laravel in here i am just creating a simple app in which user can login and register and after that write post in dashboard after logging in, I am trying to display user posts data in dashboard which is saved in database, But i am getting this error:
Undefined variable: posts (View: C:\xampp\htdocs\practiseapp\resources\views\dashboard.blade.php)
i think i have defined the posts,I can't figure out what's wrong,Any help would be appreciated Thanks....
My dashboard:
@extends('layout.master')
@section('content')
<div class="col-sm-6 col-sm-offset-3">
    <header><h3>What do you wanna say</h3></header>
    <form method="post" action="{{route('post.create')}}">
        {{csrf_field()}}
        <div class="panel-body">
        <div class="form-group">
            <textarea class="form-control" name="body" id="body" rows="5" placeholder="Enter your post">
            </textarea>
        </div>
        <button type="submit" class="btn btn-primary">Create post</button>
    </form>
    </div>
</div>
<section class="row-posts">
    <div class="col-md-6 col-sm-offset-3">
        <header><h3>Other people posts</h3></header>
        @foreach($posts as $post)
        <article class="post">
            <p>{{ $post->body }}</p>
            <div class="info">
                posted by {{ $post->user->name}} on {{$post->created_at}}
            </div>
            <div class="interaction">
                <a href="#">Like</a>|
                <a href="#">Disike</a>|
                <a href="#">Edit</a>|
                <a href="#">Delete</a>  
            </div>
        </article>
        @endforeach
    </div>
</section>
@endsection
PostController.php
<?php
namespace App\Http\Controllers;
use App\Http\Requests;
use App\Post;
use App\UserTypes;
use Auth;
use Hashids;
use Redirect;
use Illuminate\Http\Request;
use Hash;
class PostController extends Controller
{
    public function show()
    {
        //Fetching all the posts from the database
        $posts = Post::all();
        return view('dashboard',['posts'=> $posts]);
    }
    public function store(Request $request)
    {
        $this->validate($request,[
            'body' => 'required'
        ]);
        $post = new Post;
        $post->body = $request->body;
        $request->user()->posts()->save($post);
        return redirect()->route('dashboard');      
    }
}
 
    