Created
May 8, 2017 19:21
-
-
Save waqasraza123/ca84d3d5779cde6629e47612e8d49754 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Get current page form url e.g. &page=6 | |
$currentPage = LengthAwarePaginator::resolveCurrentPage(); | |
//Create a new Laravel collection from the array data | |
$collection = new Collection($data); | |
//Define how many items we want to be visible in each page | |
$perPage = 48; | |
//Slice the collection to get the items to display in current page | |
$currentPageSearchResults = $collection->slice(($currentPage - 1) * $perPage, $perPage)->all(); | |
//Create our paginator and pass it to the view | |
$paginatedSearchResults = new LengthAwarePaginator($data, $count, $perPage); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment