本文整理汇总了PHP中Illuminate\Pagination\Paginator::currentPageResolver方法的典型用法代码示例。如果您正苦于以下问题:PHP Paginator::currentPageResolver方法的具体用法?PHP Paginator::currentPageResolver怎么用?PHP Paginator::currentPageResolver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Pagination\Paginator
的用法示例。
在下文中一共展示了Paginator::currentPageResolver方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: list
static function list($number, $page)
{
Paginator::currentPageResolver(function () use($page) {
return $page;
});
return self::show("*")->paginate($number);
}
示例2: readLog
public static function readLog($deviceId, $page)
{
Paginator::currentPageResolver(function () use($page) {
return $page;
});
return LocationLog::where('device_id', $deviceId)->orderBy('location_time', 'DESC')->simplePaginate(config('custom.item_per_page'))->all();
}
示例3: validateQuery
public function validateQuery(Request $request)
{
$modelClass = $this->model;
$queryBuilder = new $modelClass();
if (count($parameters = $request->all()) > 0) {
$handledRequestParameters = $this->handleRequestParameters($parameters);
if (isset($handledRequestParameters['queries'])) {
foreach ($handledRequestParameters['queries'] as $query) {
$queryBuilder = $this->handleQuery($queryBuilder, $query);
}
}
if (isset($handledRequestParameters['take'])) {
$queryBuilder = $queryBuilder->take($handledRequestParameters['take']);
} else {
if (isset($handledRequestParameters['pagination'])) {
$currentPage = $handledRequestParameters['pagination']['page'];
Paginator::currentPageResolver(function () use($currentPage) {
return $currentPage;
});
return $queryBuilder = $queryBuilder->paginate($handledRequestParameters['pagination']['paginate'])->setPath($this->getUrlParameters($request));
}
}
}
return $queryBuilder->get();
}
示例4: handle
/**
* Set the current page based on the page route parameter before the route's action is executed.
*
* @return \Illuminate\Http\Request
*/
public function handle($request, Closure $next)
{
Paginator::currentPageResolver(function () {
return app('paginateroute')->currentPage();
});
return $next($request);
}
示例5: handle
/**
* Set the current page based on the page route parameter before the route's action is executed.
*
* @return \Illuminate\Http\Request
*/
public function handle($request, Closure $next)
{
$page = Route::getCurrentRoute()->parameter('page', 1);
Paginator::currentPageResolver(function () use($page) {
return $page;
});
return $next($request);
}
示例6: register
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
Paginator::currentPathResolver(function () {
return $this->app['request']->url();
});
Paginator::currentPageResolver(function () {
return $this->app['request']->input('page');
});
}
示例7: __construct
public function __construct($transformer, $castTransformer, $merge, PaginationRequest $request, $defaultSort = false)
{
parent::__construct($transformer, $castTransformer, $merge);
$this->request = $request;
$this->defaultSort = $defaultSort;
Paginator::currentPageResolver(function () {
return $this->request->input(join('.', [$this->pageName, $this->pageNumber]), 1);
});
}
示例8: register
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
Paginator::currentPathResolver(function () {
return $this->app['slim']->request->getResourceUri();
});
Paginator::currentPageResolver(function ($pageName = 'page') {
return $this->app['slim']->request->params($pageName);
});
}
示例9: list
public function list(Request $request)
{
$number = $request->has('request') ? $request->number : 15;
$page = $request->has('page') ? $request->page : 1;
Paginator::currentPageResolver(function () use($page) {
return $page;
});
return self::show("*", new Authorization())->paginate($number);
}
示例10: parseRequestPagination
private function parseRequestPagination($query)
{
$page = (int) $this->getHttp()->getInput('page', 1);
$offset = (int) $this->getHttp()->getInput('offset', 2);
\Illuminate\Pagination\Paginator::currentPageResolver(function () use($page) {
return $page;
});
return $query->paginate($offset);
}
示例11: setup
/**
* Setup the pagination service.
*
* @param \Slim\Slim $app The application instance.
*/
public static function setup(Slim $app)
{
$key = $app->config('pagination.key');
if (empty($key)) {
$key = 'page';
}
Paginator::currentPageResolver(function () use($app, $key) {
return $app->request->get($key);
});
}
示例12: getRepliesWithLimit
public function getRepliesWithLimit($limit = 30)
{
Paginator::currentPageResolver(function ($pageName) use($limit) {
$page = app('request')->input($pageName);
if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) {
return $page;
}
return ceil($this->reply_count / $limit);
});
return $this->replies()->orderBy('created_at', 'asc')->with('user')->paginate($limit);
}
示例13: setCurrentPage
/**
* 设置分页对象的当前页
*/
protected function setCurrentPage()
{
$page = Input::get(self::getParameterKeyPage());
$pageSize = Input::get(self::getParameterKeyPageSize());
// validate parameters
self::validatePaginationParameters($page, $pageSize);
Paginator::currentPageResolver(function () use($page) {
return $page;
});
return $pageSize;
}
示例14: index
public function index(Request $request)
{
if (!($limit = $request->get('limit'))) {
$limit = 25;
}
if ($currentPage = $request->get('page')) {
Paginator::currentPageResolver(function () use($currentPage) {
return $currentPage;
});
}
$users = User::paginate($limit);
return $this->response->paginator($users, new UserTransformer());
}
示例15: index
/**
* server 运行状态
* @param Request $request
* @return \Symfony\Component\HttpFoundation\Response
*
* @api {get} /status 查询运行状态
* @apiName PostRegister
* @apiGroup Status
*/
public function index(Request $request)
{
$currentPage = 1;
if ($request->has('page')) {
$currentPage = $request->input('page');
Paginator::currentPageResolver(function () use($currentPage) {
return $currentPage;
});
}
$per_page = $request->has('per_page') ? $request->input('per_page') : 20;
$result = Notice::orderBy('id', 'DESC')->paginate($per_page)->toArray();
return view('status', ['notice' => $result['data'], 'current_page' => $currentPage, 'last_page' => $result['last_page']]);
}