title: Laravel 5, pagination results foreach getting all ids
body: <p>I have query with laravel which returns my results and paginate() at the end, problem is when i foreach it to collect all ids in array i get first page only.</p>
  
  <p>Is there a way to get those before paginate so i dont have to run the query twice?</p>
  
  <pre><code>$clients  = Client::apply($data, $dataArray)-&gt;ModelJoinCall()-&gt;orderBy($this-&gt;sortby, $this-&gt;orderby)-&gt;paginate(30); 
  </code></pre>