title: How to get count from many relations in a Grid Yii2 Search Model
body: <p>I have many relations in a model. I want to show total number of orders, products, order received in a grid view using search model for filter and export grid but I am not able to figure out how to get counts with sort. I have following relations. </p>
  
  <pre><code>public function getProducts()
  {
      return $this-&gt;hasMany(Product::className(), ['user_id' =&gt; 'user_id']);
  }
  public function getShopImages(){
      return $this-&gt;hasMany(ShopImage::className(), ['user_id' =&gt; 'user_id']);
  }
  /**
   * @return \yii\db\ActiveQuery
   */
  public function getOrders()
  {
      // Customer has_many Order via Order.customer_id -&gt; id
      return $this-&gt;hasMany(Order::className(), ['user_id' =&gt; 'user_id']);
  }
  
  /**
   * @return \yii\db\ActiveQuery
   */
  public function getOrderrs()
  {
      // Customer has_many Order via Order.customer_id -&gt; id
      return $this-&gt;hasMany(Order::className(), ['merchant_id' =&gt; 'user_id']);
  }
  </code></pre>
  
  <p>I need count of each one. Any Idea, how to do it ?</p>