<?php namespace App\Http\Controllers;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
class MemberController extends Controller {
public function search(Request $request)
{
$queryResults = [
'item1',
'item2',
'item3',
'item4',
'item5',
'item6',
'item7',
'item8',
'item9',
'item10'
];
$currentPage = LengthAwarePaginator::resolveCurrentPage();
$collection = new Collection($queryResults);
$perPage = 5;
$currentPageSearchResults = $collection->slice(($currentPage - 1) * $perPage, $perPage)->all();
$paginatedSearchResults= new LengthAwarePaginator($currentPageSearchResults, count($collection), $perPage);
$paginatedSearchResults->setPath($request->url());
$paginatedSearchResults->appends($request->except(['page']));
return view('search', ['results' => $paginatedSearchResults]);
}
?>