Created
October 25, 2019 11:26
-
-
Save diloabininyeri/f92d350bae637dec622dd61f01913f62 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
namespace App\Http\Controllers; | |
use App\Paginator; | |
use Illuminate\Http\Request; | |
use Illuminate\Pagination\LengthAwarePaginator; | |
class Deneme extends Controller | |
{ | |
function index(Request $request) | |
{ | |
$data=[]; | |
foreach (range(1,50) as $i) | |
{ | |
$std=new \stdClass(); | |
$std->id=$i; | |
$data[]=$std; | |
} | |
$collect = collect($data); | |
$currentPage = LengthAwarePaginator::resolveCurrentPage(); | |
$itemCollection = collect($collect); | |
$perPage = 10; | |
$currentPageItems = $itemCollection->slice(($currentPage * $perPage) - $perPage, $perPage)->all(); | |
$paginatedItems= new LengthAwarePaginator($currentPageItems , count($itemCollection), $perPage); | |
$paginatedItems->setPath($request->url()); | |
return view('deneme',['items' => $paginatedItems]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment