I want to get some field data in database in several different tables and i have made relationship between tables in post model , and in ListingPageController i have assigned post model and created variable named $posts to use it in list.blade.php page while i am trying to use it will give me this error please help
Following code is ListingPageController page:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Post;
class ListingPageController extends Controller
{
    public function index(){
        return view('front.listing');
    }
    public function listing($id){ 
         $posts = Post::with(['comments','category','creator'])
                      ->where('status',1)
                      ->where('category_id',$id)
                      ->orWhere('created_by',$id)
                      ->orderBy('id','DESC')->paginate(3); 
       return view('front.listing',compact('posts'));
  }
}
Below code is listing.blade.php page
@foreach($posts as $key=>$post)
                @if($key === 0)
<div class="entity_wrapper">
    <div class="entity_title header_purple">
        <h1><a href="{{ url('/category') }}/{{ $post->category_id }}">{{ $post->category->name }}</a></h1>
    </div>
    <!-- entity_title -->
    <div class="entity_thumb">
        <img class="img-responsive" src="{{ asset('post') }}/{{ $post->main_image }} " alt="{{ $post->title }}">
    </div>
    <!-- entity_thumb -->
    <div class="entity_title">
        <a href="{{ url('/details') }}/{{ $post->slug }}" target="_blank"><h3> {{ $post->title }} </h3></a>
    </div>
    <!-- entity_title -->
    <div class="entity_meta">
        <a href="#">{{ date('F j- Y',strtotime($post->created_at)) }}</a> , by: <a href="{{ url('/author') }}/{{ $post->creator->id }}">{{ $post->creator->name }} </a>
    </div>
    <!-- entity_meta -->
    <div class="entity_content">
        {{ str_limit( $post->short_description,200,'...' )  }}
    </div>
    <!-- entity_content -->
    <div class="entity_social">
        <span><i class="fa fa-comments-o"></i>{{ count($post->comments) }} <a href="#"> Comments</a></span>
    </div>
    <!-- entity_social -->
</div>
<!-- entity_wrapper -->
      @else
    @if($key === 1)
<div class="row">
    @endif <!-- first if will be ended here -->
    <div class="col-md-6" style="min-height: 555px;margin-bottom:2%">
        <div class="category_article_body">
            <div class="top_article_img">
                <img class="img-fluid" src="{{ asset('post') }}/{{ $post->list_image }}" alt="{{ $post->title }}">
            </div>
            <!-- top_article_img -->
            <div class="category_article_title">
                <h5>
                    <a href="{{ url('/details') }}/{{ $post->slug }}" target="_blank"> {{ $post->title }} </a>
                </h5>
            </div>
            <!-- category_article_title -->
            <div class="article_date">
                <a href="#">{{ date('F j- Y',strtotime($post->created_at)) }}</a> , by: <a href="{{ url('/author') }}/{{ $post->creator->id }}">{{ $post->creator->name }}</a>
            </div>
            <!-- article_date -->
            <div class="category_article_content">
               {{ str_limit( $post->short_description,100,'...' )  }}
            </div>
            <!-- category_article_content -->
            <div class="article_social">
                <span><i class="fa fa-comments-o"></i>{{ count($post->comments) }} <a href="#"> Comments</a></span>
            </div>
            <!-- article_social -->
         </div>
        <!-- category_article_body -->
        </div>
    <!-- col-md-6 -->
    @if($loop->last)
    </div>
      @endif
        @endif
         @endforeach
 
     
     
    