title: How add/append new items by key Laravel Collection
body: <p>I don't know if it's the best or right way to do it, but in PHP, I simply would.</p>
  
  <pre><code>        $array = [];
  
          $array['CODE-123'][] = [
              'name' =&gt; 'NAME 001',
              'lastname' =&gt; 'LASTNAME 001',
          ];
  
          $array['CODE-456'][] = [
              'name' =&gt; 'NAME 004',
              'lastname' =&gt; 'LASTNAME 004',
          ];
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/plxi0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/plxi0.png" alt="php array"></a></p>
  
  <pre><code>        $array['CODE-123'][] = [
              'name' =&gt; 'NAME 002',
              'lastname' =&gt; 'LASTNAME 002',
          ];
  
  
          $array['CODE-456'][] = [
              'name' =&gt; 'NAME 005',
              'lastname' =&gt; 'LASTNAME 005',
          ];
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/zRsRB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zRsRB.png" alt="php array append by key"></a></p>
  
  <p><b>But the point is</b>: How to proceed to get the same result but using Laravel Collection? That is, how can I add/append new elements using the 'desired key' from a Laravel Collection?</p>
  
  <p>If I try to use the <code>put()</code>, it overwrites the original key content.</p>
  
  <pre><code>        $collection = collect();
  
          $collection-&gt;put('CODE-123', [
              'name' =&gt; 'NAME 001',
              'lastname' =&gt; 'LASTNAME 001',
          ]);
  
          $collection-&gt;put('CODE-456', [
              'name' =&gt; 'NAME 004',
              'lastname' =&gt; 'LASTNAME 004',
          ]);
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/qZ5TU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qZ5TU.png" alt="enter image description here"></a></p>
  
  <p>For example, I want to add some new items, in the key 'CODE-123', if it were a native PHP array, I would use a pair of square brackets, but using collection, I couldn't and it generates an ErrorException (E_NOTICE) Indirect modification of overloaded element.</p>
  
  <pre><code>$collection['CODE-123'][] = 'some new item...';
  </code></pre>