Get the query string variable used to store the page. (Not available when using simplePaginate). The number of items to be shown per page.ĭetermine the total number of matching items in the data store. (Not available when using simplePaginate).ĭetermine if the paginator is on the first page. Get the page number of the last available page. Get the result number of the last item in the results. Get the result number of the first item in the results.ĭetermine if there are enough items to split into multiple pages.ĭetermine if there are more items in the data store. Get the number of items for the current page. Paginator / LengthAwarePaginator Instance MethodsĮach paginator instance provides additional pagination information via the following methods: Method For example, if you want the paginator to generate links like, you should pass /admin/users to the withPath method: However, the paginator's withPath method allows you to customize the URI used by the paginator when generating links. If you're unsure how to do this, check out the array_slice PHP function.īy default, links generated by the paginator will match the current request's URI. When manually creating a paginator instance, you should manually "slice" the array of results you pass to the paginator. In other words, the Paginator corresponds to the simplePaginate method on the query builder, the CursorPaginator corresponds to the cursorPaginate method, and the LengthAwarePaginator corresponds to the paginate method. The LengthAwarePaginator accepts almost the same arguments as the Paginator however, it requires a count of the total number of items in the result set. The Paginator and CursorPaginator classes do not need to know the total number of items in the result set however, because of this, these classes do not have methods for retrieving the index of the last page. You may do so by creating either an Illuminate\Pagination\Paginator, Illuminate\Pagination\LengthAwarePaginator or Illuminate\Pagination\CursorPaginator instance, depending on your needs. Sometimes you may wish to create a pagination instance manually, passing it an array of items that you already have in memory.
0 Comments
Leave a Reply. |