title: Get number of rows in Laravel's Eloquent before using "take" and "skip"
body: <p>I want to query my Laravel model using eloquent for results that may need to match some where clauses, then <code>take</code> and <code>skip</code> predefined numbers.</p>
  
  <p>This isn't a problem in itself, but I also need to know the number of rows that were found in the query before reducing the result set with take and skip - so the original number of matches which could be every row in the table if no where clauses are used or a few if either is used.</p>
  
  <p>What I want to do could be accomplished by making the query twice, with the first omitting "<code>-&gt;take($iDisplayLength)-&gt;skip($iDisplayStart)</code>" at the end and counting that, but that just seems messy.</p>
  
  <p>Any thoughts?</p>
  
  <pre><code>$contacts = Contact::where(function($query) use ($request)
  {
  
      if (!empty($request['firstname'])) {
          $query-&gt;where(function($query) use ($request)
          {
              $query-&gt;where('firstname', 'LIKE', "%{$request['firstname']}%");
  
          });
      }   
  
      if (!empty($request['lastname'])) {
          $query-&gt;where(function($query) use ($request)
          {
              $query-&gt;where('lastname', 'LIKE', "%{$request['lastname']}%");
  
          });
      }     
  
  })
  -&gt;take($iDisplayLength)-&gt;skip($iDisplayStart)-&gt;get();
  
  $iTotalRecords = count($contacts);
  </code></pre>