Skip to main content

Command Palette

Search for a command to run...

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

Updated
1 min read
How to use skip() and take() in Laravel Query?
R

Full Stack Developer with a passion for building web applications. PHP, Node.js, Laravel, MySQL, MongoDB. Love collaborating & making a difference

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;

More from this blog

R

Raja Muhammad Asher - Senior Software Engineer - Full Stack Developer

157 posts

Full Stack Developer with a passion for building web applications. PHP, Node.js, Laravel, ExpressJS, MySQL, MongoDB. Love collaborating & making a difference