title: How to create nested collections in Laravel?
body: <p>I'm trying to create a nested collection in Laravel. Currently I'm using multi-dimensional arrays:</p>
  
  <pre><code>foreach ($combination-&gt;attributes as $attr) {
          $groups['group'][$attr-&gt;group-&gt;language-&gt;name][] = $attr-&gt;language;
  }
  </code></pre>
  
  <p>How would I replicate that using Laravel collections? I want to be able to leverage the lists method and groupBy methods?</p>
  
  <p>Here's what the data looks like:</p>
  
  <pre><code>array:1 [▼
    "group" =&gt; array:2 [▼
      "Finish" =&gt; array:3 [▼
        0 =&gt; AttributeLanguage {#257 ▶}
        1 =&gt; AttributeLanguage {#234 ▶}
        2 =&gt; AttributeLanguage {#256 ▶}
      ]
      "Print Size" =&gt; array:3 [▼
        0 =&gt; AttributeLanguage {#252 ▶}
        1 =&gt; AttributeLanguage {#252 ▶}
        2 =&gt; AttributeLanguage {#252 ▶}
      ]
    ]
  ]
  </code></pre>