title: How to stack same database results based on multiple columns in a Laravel project?
body: <p>In a Laravel project I have a <code>shapes</code> table that has the following columns:</p>
  <p><code>width, height, weight, color_id</code></p>
  <p>How can I 'stack' all the shapes that are the same with a matching width, height, weight and color?</p>
  <p>So far, I've tried to use the <code>groupBy</code> method, but when I use multiple criteria, it puts the results in a collection inside of collection inside of collection etc.</p>
  <pre><code>$stacks = Shape::latest()-&gt;get()-&gt;groupBy(['width', 'height', 'weight', 'color_id']);
  </code></pre>
  <p>My overall goal is to get an array/collection with all available &quot;stacks&quot;, and in every stack to have the objects that are matching. Any suggestions how to do this?</p>