title: addGlobalScope withCount relationship's relationship
body: <p>I have a 3 models: Phone, Product and Store.</p>
  
  <p>A phone has many Product which belongs to a Store.</p>
  
  <p>I am trying to add a golbal scope so that every time I load a phone, products and stores counts are loaded automatically.</p>
  
  <p>products_count works fine, however stores_count is a bit tricky since store is not a Phone's relationship but a Product's.</p>
  
  <p>I have tried the following but it gives me an error "Method getRelated does not exist.", I assume because stores() now returns a collection.</p>
  
  <p>Any ideas as to how I could add the stores_count?</p>
  
  <pre><code> public static function boot(){
  
      parent::boot();
  
      static::addGlobalScope('products', function ($builder){
  
          $builder-&gt;withCount('products');
          $builder-&gt;withCount('stores');  &lt;----- gives error
      });
  }
  
  public function products(){
  
      return $this-&gt;hasMany(Product::class);
  }
  
  public function stores(){
      $store_ids = $this-&gt;products()-&gt;get(['store_id'])-&gt;unique();
  
      return Store::find($store_ids);
  }
  </code></pre>
  
  <p><strong>Update after @Sandeesh answer.</strong></p>
  
  <p>I tried to use hasManyThrough but it returns an empty collection which is wrong.
  When I dd($phone->products); I can see 7 products which have 3 different stores.</p>
  
  <pre><code>public function stores(){
  
      return $this-&gt;hasManyThrough(Store::class, Product::class,
          'store_id', 'id');
  }
  </code></pre>
  
  <p>Database schema</p>
  
  <pre><code>Phone
  -id
  
  Product
  -id
  -phone_id
  -product_id
  -store_id
  
  Store
  -id
  </code></pre>
  
  <p><strong>Update 2</strong></p>
  
  <p>So I managed to get the produced query from the stores() method above.</p>
  
  <pre><code>select `phones`.*, 
  (select count(*) from `products` where `phones`.`id` = `products`.`phone_id`) as `products_count`, 
  (select count(*) from `stores` inner join `products` on `products`.`id` = `stores`.`id` where `phones`.`id` = `products`.`store_id`) as `stores_count` 
  from `phones` where `slug` = ? limit 1
  </code></pre>
  
  <p>The problem is in the third line. The query is messed up, not sure what is wrong with the relationship though.</p>