title: Laravel: How to make one collection out of array of collections?
body: <p>I use this query to get ids into a variable:</p>
  
  <pre><code>$ids = DB::table('note_user')-&gt;select('note_id')-&gt;where('user_id', $user_id)-&gt;get('note_id');
  </code></pre>
  
  <p>Since I have two notes that belong to one user I get </p>
  
  <pre><code>[{"note_id":1},{"note_id":2}]
  </code></pre>
  
  <p>This appears to be an array of collections and every <a href="https://laravel.com/docs/5.2/collections#available-methods" rel="nofollow">Laravel collection method</a> I attempt to apply to it returns an error. For example,</p>
  
  <pre><code>$flattened = $ids-&gt;flatMap(function ($values) {
      return $values;
  });
  </code></pre>
  
  <p>returns</p>
  
  <blockquote>
    <p>Fatal error: Call to a member function flatMap() on array</p>
  </blockquote>
  
  <p>Is there any way to turn </p>
  
  <pre><code>[{"note_id":1},{"note_id":2}]
  </code></pre>
  
  <p>into</p>
  
  <p><code>[1, 2]</code>?    </p>