Created
October 25, 2019 09:37
-
-
Save diloabininyeri/cdc873c09b0443058614a33b9aebd71d 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 Illuminate\Http\Request; | |
| use Illuminate\Pagination\LengthAwarePaginator; | |
| class Deneme extends Controller | |
| { | |
| function index(Request $request) | |
| { | |
| $contact_list = []; | |
| foreach (range(1, 100) as $i) { | |
| $std = new \stdClass(); | |
| $std->id = $i; | |
| $std->name = "dd" . $i; | |
| $contact_list[] = $std; | |
| } | |
| $page = isset($request->page) ? $request->page : 1; // Get the page=1 from the url | |
| $perPage = 2; // Number of items per page | |
| $offset = ($page * $perPage) - $perPage; | |
| $entries = new LengthAwarePaginator( | |
| array_slice($contact_list, $offset, $perPage, true), | |
| count($contact_list), // Total items | |
| $perPage, // Items per page | |
| $page, // Current page | |
| ['path' => $request->url(), 'query' => $request->query()] // We | |
| ); | |
| return view('deneme', compact('entries')); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment