mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-11-25 07:17:03 +08:00
30 lines
725 B
PHP
30 lines
725 B
PHP
|
<?php namespace BookStack\Providers;
|
||
|
|
||
|
|
||
|
use Illuminate\Support\ServiceProvider;
|
||
|
use Illuminate\Pagination\Paginator;
|
||
|
|
||
|
class PaginationServiceProvider extends ServiceProvider
|
||
|
{
|
||
|
/**
|
||
|
* Register the service provider.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function register()
|
||
|
{
|
||
|
Paginator::currentPathResolver(function () {
|
||
|
return baseUrl($this->app['request']->path());
|
||
|
});
|
||
|
|
||
|
Paginator::currentPageResolver(function ($pageName = 'page') {
|
||
|
$page = $this->app['request']->input($pageName);
|
||
|
|
||
|
if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) {
|
||
|
return $page;
|
||
|
}
|
||
|
|
||
|
return 1;
|
||
|
});
|
||
|
}
|
||
|
}
|