| 1 |
<?php |
| 2 |
|
| 3 |
namespace Illuminate\Pagination; |
| 4 |
|
| 5 |
class PaginationState |
| 6 |
{ |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
public static function resolveUsing($app) |
| 14 |
{ |
| 15 |
Paginator::viewFactoryResolver(fn () => $app['view']); |
| 16 |
|
| 17 |
Paginator::currentPathResolver(fn () => $app['request']->url()); |
| 18 |
|
| 19 |
Paginator::currentPageResolver(function ($pageName = 'page') use ($app) { |
| 20 |
$page = $app['request']->input($pageName); |
| 21 |
|
| 22 |
if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) { |
| 23 |
return (int) $page; |
| 24 |
} |
| 25 |
|
| 26 |
return 1; |
| 27 |
}); |
| 28 |
|
| 29 |
Paginator::queryStringResolver(fn () => $app['request']->query()); |
| 30 |
|
| 31 |
CursorPaginator::currentCursorResolver(function ($cursorName = 'cursor') use ($app) { |
| 32 |
return Cursor::fromEncoded($app['request']->input($cursorName)); |
| 33 |
}); |
| 34 |
} |
| 35 |
} |