As you can see, the syntax is nearly identical to paginating query builder results: use App\Models\User In this example, we will paginate the App\Models\User model and indicate that we plan to display 15 records per page. Therefore, if you only need to display simple "Next" and "Previous" links in your application's UI, you may use the simplePaginate method to perform a single, efficient query: $users = DB::table('users')->simplePaginate(15) However, if you do not plan to show the total number of pages in your application's UI then the record count query is unnecessary. This is done so that the paginator knows how many pages of records there are in total. The paginate method counts the total number of records matched by the query before retrieving the records from the database. In this case, let's specify that we would like to display 15 items per page: DB::table('users')->paginate(15) In this example, the only argument passed to the paginate method is the number of items you would like displayed "per page". This value is automatically detected by Laravel, and is also automatically inserted into links generated by the paginator. By default, the current page is detected by the value of the page query string argument on the HTTP request. The paginate method automatically takes care of setting the query's "limit" and "offset" based on the current page being viewed by the user. The simplest is by using the paginate method on the query builder or an Eloquent query. There are several ways to paginate items. Laravel's paginator is integrated with the query builder and Eloquent ORM and provides convenient, easy-to-use pagination of database records with zero configuration.īy default, the HTML generated by the paginator is compatible with the Tailwind CSS framework however, Bootstrap pagination support is also available. We hope Laravel's approach to pagination will be a breath of fresh air. In other frameworks, pagination can be very painful. Paginator and LengthAwarePaginator Instance Methods.