title: How to properly merge multiple collections in Laravel
body: <p>I want to merge multiple collections into one. I do have a solution, which is the following:</p>
  
  <pre><code>$allItems = $collection1-&gt;merge($collection2)
                          -&gt;merge($collection3)
                          -&gt;merge($collection4)
                          -&gt;merge($collection5);
  </code></pre>
  
  <p>This actually does work, but I run into problems in cases where some or all of the collections contain no objects. I get an error along the lines of <code>call to merge() on non object</code>.</p>
  
  <p>I actually tried to create an array of all of the collections, and then iterate through them, while checking their validity, but it didn't work and I feel it wasn't very elegant.</p>
  
  <p>How can I elegantly iterate through this process of merging multiple collections, while taking into account that some or all of the collections might be empty or invalid? Appreciated! </p>