Skip and take everything?

In short, how can I skip 10 rows and then get the rest of the table?

User::skip(10)->all(); 

The above does not work, but it gives you an idea of ​​what I'm looking for.

+5
source share
3 answers

Try the following:

 $count = User::count(); $skip = 10; User::skip($skip)->take($count - $skip)->get(); 

With a single request:

 User::skip($skip)->take(18446744073709551615)->get(); 

This is ugly, but this is an example from the official MySQL manual :

To get all the lines from a specific offset to the end of the set result, you can use some large amount for the second parameter. This statement retrieves all rows from the 96th row to the last:

 SELECT * FROM tbl LIMIT 95,18446744073709551615; 
+3
source

try something like this, that's right.

 $temp = User::count(); $count = $temp - 10; $data = User::take($count)->skip(10)->get(); 
+2
source

Laravel 5 returns an Eloquent result as a Collection. That way you can use the collice function slice () ;

 $users = User::get(); $slicedUsers = $users->slice(10); 
+1
source

All Articles