Просмотр файла vendor/illuminate/pagination/PaginationState.php

Размер файла: 989B
  1. <?php
  2.  
  3. namespace Illuminate\Pagination;
  4.  
  5. class PaginationState
  6. {
  7. /**
  8. * Bind the pagination state resolvers using the given application container as a base.
  9. *
  10. * @param \Illuminate\Contracts\Foundation\Application $app
  11. * @return void
  12. */
  13. public static function resolveUsing($app)
  14. {
  15. Paginator::viewFactoryResolver(function () use ($app) {
  16. return $app['view'];
  17. });
  18.  
  19. Paginator::currentPathResolver(function () use ($app) {
  20. return $app['request']->url();
  21. });
  22.  
  23. Paginator::currentPageResolver(function ($pageName = 'page') use ($app) {
  24. $page = $app['request']->input($pageName);
  25.  
  26. if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) {
  27. return (int) $page;
  28. }
  29.  
  30. return 1;
  31. });
  32.  
  33. Paginator::queryStringResolver(function () use ($app) {
  34. return $app['request']->query();
  35. });
  36. }
  37. }