For Laravel paging, bring a paginate method, very useful, but there are limitations.
So I wrote a page of my own for this, the specific code is as follows
<?php namespace ...; Use ...;/** * Custom paging class, suitable for small data queries, multi-data when not recommended * Class Custompaginate * @package app\tools\paginate */class custompaginate{/** * Custom number of Components page * @param $data = return result * @param $page * @param $limit * @return Mixed */public static function Pagi Nate ($data, $page = 1, $limit = ten) {if (!is_numeric ($page) | |!is_numeric ($LIMIT)) {return false; } $count = count ($data); $data = Array_slice ($data, ($page-1) * $limit, $limit); return new Lengthawarepaginator ($data, $count, $limit, $page); }/** * Parameter interpretation method of external exposure * @param $data = array|collection Remember to support only these two * @param $page = Current Page * @param $limit = show a few of each page * @return Array|false * Returns the result of an array of call instances: Custompaginate::p aginatetoarray ($data, $request->page, $request->limit); */public static function Paginatetoarray ($data, $page = 1, $limit = ten) {$isValidate = Self::validate ($data, $pa GE, $limit); Verify if ($isValidate = = = False) {return false; } $res = selF::p aginate ($data, $page, $limit)->toarray (); Paging data conversion to an array//previous | | Next page = Path if ($res [' prev_page_url ']! = null) {$prev _page = $page-1; $res [' prev_page_url '] = Paginator::resolvecurrentpath (). "? page=". $prev _page. "&limit=". $limit; if ($res [' next_page_url ']! = null) {$next _page = $page + 1; $res [' next_page_url '] = Paginator::resolvecurrentpath (). "? page=". $next _page. "&limit=". $limit; } return $res; }/** * Verify that the parameters are valid */public static function validate (& $data, & $page = 1, & $limit = ten) {$page = empt Y ($page)? 1: $page; $limit = Empty ($limit)? Ten: $limit; if (!is_array ($data) &&! $data instanceof Collection) {return false;//"custom paging method only supports array data and collection data"; } if (!is_numeric ($page) | |!is_numeric ($LIMIT)) {return false;//"page limit parameter only supports numbers"; } if ($data instanceof Collection) {return $data = $data->toarray (); } return $data;}}