2016-08-14 19:29:35 +08:00
|
|
|
<?php namespace BookStack\Providers;
|
|
|
|
|
|
|
|
|
2016-09-18 01:22:04 +08:00
|
|
|
use Illuminate\Pagination\PaginationServiceProvider as IlluminatePaginationServiceProvider;
|
2016-08-14 19:29:35 +08:00
|
|
|
use Illuminate\Pagination\Paginator;
|
|
|
|
|
2016-09-18 01:22:04 +08:00
|
|
|
class PaginationServiceProvider extends IlluminatePaginationServiceProvider
|
2016-08-14 19:29:35 +08:00
|
|
|
{
|
2016-09-18 01:22:04 +08:00
|
|
|
|
2016-08-14 19:29:35 +08:00
|
|
|
/**
|
|
|
|
* Register the service provider.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
2016-09-18 01:22:04 +08:00
|
|
|
Paginator::viewFactoryResolver(function () {
|
|
|
|
return $this->app['view'];
|
|
|
|
});
|
|
|
|
|
2016-08-14 19:29:35 +08:00
|
|
|
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;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|