title: laravel get relation table throught another
body: <p>I've got 3 tables:</p>
  
  <pre><code>users: (App\Users)
  id|name|email
  
  coupons: (App\Coupons)
  id|coupon_code|user_id|discount
  
  orders: (App\Orders)
  id|order_id|total|coupon_code
  </code></pre>
  
  <p>I need to connect users with orders, so I can do sort by orders count, I'm trying like this:</p>
  
  <p>orders function belogns to App\User</p>
  
  <pre><code>public function orders()
  {
      return $this-&gt;hasManyThrough('App\Coupons', 'App\Orders', 'coupon', 'coupon_code');
  }
  </code></pre>
  
  <p>Is there way to get relation for this tables, so I could use:</p>
  
  <pre><code>$users = App\Users-&gt;withCount('orders')-&gt;orderBy('orders_count', 'desc');
  </code></pre>
  
  <p>I can get correct result by:</p>
  
  <pre><code>$coupons = App\Coupons::where('user_id', '=', $this-&gt;id);
  return App\Orders::whereIn('coupon', $coupons-&gt;pluck('coupon_code'));
  </code></pre>
  
  <p>but then I can't do sort on this column</p>