title: Count function return 0 in laravel
body: <p>I want to show count of product for company using <code>count</code> function but it return <code>0</code> why? 
  And what is the true syntax for relation?
  and how I can get the sql query from function of model?</p>
  
  <p><strong>Agent_Company.php</strong></p>
  
  <pre><code>class Agent_Company extends Model
  {
      //
      protected $table='agent_companies';
      protected $primaryKey='id';
      protected $fillable=['companyName','description','id_image'];
  
      public function products(){
          return $this-&gt;hasMany('App\Product','id','id_company');
      }
      public function image(){
          return $this-&gt;belongsTo('App\Image','id_image');
      }
  }
  </code></pre>
  
  <p><strong>Product.php</strong></p>
  
  <pre><code>class Product extends Model
  {
      //
      protected $table='products';
      protected $primaryKey='id';
      protected $fillable=[
              'product','video','id_company','id_image',
      ];
      public function Image(){
          return $this-&gt;belongsTo('App\Image');
      }
      public function Agent_Company(){
          return $this-&gt;belongsTo('App\Agent_Company','id_company','id');
      }
  }
  </code></pre>
  
  <p>there is the view:</p>
  
  <pre><code>&lt;div class="container"&gt;
      {{$agent_Company-&gt;links()}}
      &lt;div class="row" id="company"&gt;
          @foreach($agent_Company as $item)
              &lt;div class="card col-md-4" style="width: 300px; max-height: 500px;"&gt;
                  &lt;div class="card-header"&gt;
                      &lt;h2&gt;{{$item-&gt;companyName}}&lt;/h2&gt;
                  &lt;/div&gt;
                  &lt;img src="{{'agent_Companye_Images/'.$item-&gt;image-&gt;image}}" class="card-img-top"
                       alt="{{$item-&gt;image-&gt;alt}}" style="width: 300px; height: 300px"&gt;
                  &lt;div class="card-body" style="overflow:auto"&gt;
                      &lt;h5 class="card-title"&gt;Product:{{DD($item-&gt;Products-&gt;count())}}&lt;/h5&gt;
                      &lt;span class="card-title"&gt;
                          &lt;a href="" class=" btn btn-primary"&gt; Go to Company&lt;/a&gt;
                          {{$item-&gt;description}}
                      &lt;/span&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          @endforeach
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>