title: Laravel collection group by
body: <p>I have a search function to search for expenses by a certain date, month, string, whatever. It returns a collection:</p>
  
  <p><a href="https://i.stack.imgur.com/LARfI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LARfI.png" alt="enter image description here"></a></p>
  
  <p>So far so good. I can display all returned <code>Expenses</code>. Now, what I want to do is, display also a total expense count and total amount, grouped by the <code>description_id</code>. If I simply do <code>$result-&gt;groupBy('description_id)</code>, I just get a set of collections, from which I can display the total count and total amount, but not the name of the description. Example of what I want:</p>
  
  <pre><code>Grouped Results (By Expense):
  
  Description Name: &lt;-- Issue displaying this
  Total Expenses: 3
  Total Amount: 53444
  </code></pre>
  
  <p>The description name can only be obtained via the relation between <code>Expense</code> and <code>Description</code>. An Expense belongsTo a description.</p>
  
  <p>Is it at all possible to achieve what I want, when working with my collection, or should I perform a seperate query for those results? (undesired)</p>