How to use skip() and take() in Laravel Query?

Photo by Andrew Hall on Unsplash

How to use skip() and take() in Laravel Query?

skip() and take() are commonly used methods when querying the database to paginate or limit the number of records returned. These methods are particularly useful when you want to implement pagination or control the number of records fetched from the database.

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

is equivalent to

select * from `users` limit 5 offset 10;