title: Implementing group_by and having in Laravel using Eloquent
body: <p>I am having trouble implementing the group_by and having queries using Eloquent in Laravel. </p>
  
  <p>Here is the scenario:</p>
  
  <pre><code>orders
   - id
   - qty
  
  deliveries
   - id
   - qty
   - order_id
  </code></pre>
  
  <p>I want to use a join to display the orders with incomplete deliveries as well as the corresponging balance:</p>
  
  <pre><code>Order::left_join('deliveries', 'orders.id', '=', 'deliveries.order_id')
       -&gt;select(array('orders.*'), DB::raw('orders.qty - IFNULL(sum(deliveries.qty),0) AS balance')))
       -&gt;group_by('order_id')
       -&gt;having('balance', '&gt;', 0)
       -&gt;get();
  </code></pre>
  
  <p>The 'balance' value works fine without the 'having' clause.  On adding the 'having' clause however, the resulting table doesn't display any rows. Does anyone have any ideas?</p>
  
  <p>Thanks in advance!</p>