title: Group Collection by multiple column - Laravel
body: <p>So, i have this collection in laravel :</p>
  
  <pre><code>$collection = [
   {OC: "3.01", C: "922.76", D: "0"},
   {OC: "3.01", C: "0", D: "78004027.00"},
   {OC: "3.02", C: "0", D: "116442.60"},
   {OC: "3.03", C: "0", D: "833.83"},
   {OC: "3.04", C: "772.50", D: "0"},
   {OC: "3.04", C: "0", D: "3345.50"}
  ];
  </code></pre>
  
  <p>i need to group so i have one OC of a kind, each one can have one or two records (one for C != 0 and one for D != 0), in this case for example the expected result is:</p>
  
  <pre><code>$collection = [
   {OC: "3.01", C: "922.76", D: "78004027.00"},
   {OC: "3.02", C: "0", D: "116442.60"},
   {OC: "3.03", C: "0", D: "833.83"},
   {OC: "3.04", C: "772.50", "3345.50"},
  ];
  </code></pre>
  
  <p>whats the most effective way i can do it? can someone please shed a light, i tried using ->groupBy but i can only group by OC and its not solving my problem</p>
  
  <p>much appreciated</p>