Laravel manually paging method

Illuminate use \ Pagination \ LengthAwarePaginator; 

public function index (Request Request $) { 
    $ List = [...];
     // Pages default 1 
    $ Page = $ request-> Page:? 1 ;
     // page article number 
    $ perPage = 10 ;
     // calculate the initial positions per tab 
     $ offset = ($ * $ Page perPage) - $ perPage;
      // instantiate LengthAwarePaginator class, and passing the corresponding parameter 
     $ = List new new LengthAwarePaginator (array_slice ( List $, $ offset, 
     $ perPage, to true ), COUNT ($ List), perPage $, $ Page, [ ' path ' => 
     $request->url(), 'query' => $request->query()]);
     return view('admin.user.index', compact('list'), 
     compact('query'));
}
    

 

Guess you like

Origin www.cnblogs.com/lamp01/p/11497264.html