title: How to add limit to array data fetched from database in laravel
body: <p>I'm retrieving the rows from user table and I'm using below code.
  <br></p>
  
  <pre><code>&lt;?php $user = User::get(); ?&gt;
  </code></pre>
  
  <p>I want to add array limit for $user data. I don't want to use <code>paginate();</code>. To add limit I'm using below code but it's not working 
  <br><br><code>$users = array_slice($users, 0,2);</code> 
  <br><br>
  But it's showing below error message</p>
  
  <blockquote>
    <p>exception 'ErrorException' with message 'array_slice() expects
    parameter 1 to be array, object given' in........</p>
  </blockquote>
  
  <p>How to I add limit to <code>$user</code>?</p>