public function LengthAwarePaginator($items, $resultsPerPage = 4)
    {
        //Get current page form url e.g. &page=6
        $currentPage = LengthAwarePaginator::resolveCurrentPage();

        //Create a new Laravel collection from data
        $collection = new Collection($items);

        //Slice the collection to get the items to display in current page
        $currentPageSearchResults = $collection->slice(($currentPage - 1) * $resultsPerPage, $resultsPerPage) -> all();

        //Create our paginator and pass it to the view
        return new LengthAwarePaginator($currentPageSearchResults, count($collection), $resultsPerPage);
    }
public function LengthAwarePaginator($items, $resultsPerPage = 4)
    {
        //Get current page form url e.g. &page=6
        $currentPage = LengthAwarePaginator::resolveCurrentPage();

        //Create a new Laravel collection from data
        $collection = new Collection($items);

        //Slice the collection to get the items to display in current page
        $currentPageSearchResults = $collection->slice(($currentPage - 1) * $resultsPerPage, $resultsPerPage) -> all();

        //Create our paginator and pass it to the view
        return new LengthAwarePaginator($currentPageSearchResults, count($collection), $resultsPerPage);
    }
public function LengthAwarePaginator ( $ items , $ resultsPerPage = 4 ) { //Get current page form url e.g. &page=6 $ currentPage = LengthAwarePaginator :: resolveCurrentPage ( ) ; //Create a new Laravel collection from data $ collection = new Collection ( $ items ) ; //Slice the collection to get the items to display in current page $ currentPageSearchResults = $ collection -> slice ( ( $ currentPage - 1 ) * $ resultsPerPage , $ resultsPerPage ) -> all ( ) ; //Create our paginator and pass it to the view return new LengthAwarePaginator ( $ currentPageSearchResults , count ( $ collection ) , $ resultsPerPage ) ; }
Initializes a LengthAwarePaginator instance

@param array|object $items
@param int          $resultsPerPage Define how many items we want to be visible in each page

@return LengthAwarePaginator
Initializes a LengthAwarePaginator instance