Method Illuminate\Database\Eloquent\Collection::skip does not exist – Laravel 5.8

Solution:

Tl;dr For 5.8, the solution is to use slice(); So it becomes to $user->slice(20)->take(10);

If you wonder why $users = User::skip(20)->take(10)->get(); works, but the code below is not working.

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

This is because, when you use Eloquent to query database many chainable methods (like: whereskip and many others) will translate to query builder, but when you call get it’s going to return the whole result from database to your local memory, so it becomes to Illuminate\Database\Eloquent\Collectioninherents from Illuminate\Support\Collection.

For 5.8 the Collection does not have skip method. So you get that error.

It’s added since 6, so you in order to achieve what you want you either update to 6 + or use slice().