2016-08-14 07:29:35 -04:00
|
|
|
<?php namespace BookStack\Providers;
|
|
|
|
|
2016-09-17 13:22:04 -04:00
|
|
|
use Illuminate\Pagination\PaginationServiceProvider as IlluminatePaginationServiceProvider;
|
2016-08-14 07:29:35 -04:00
|
|
|
use Illuminate\Pagination\Paginator;
|
|
|
|
|
2016-09-17 13:22:04 -04:00
|
|
|
class PaginationServiceProvider extends IlluminatePaginationServiceProvider
|
2016-08-14 07:29:35 -04:00
|
|
|
{
|
2016-09-17 13:22:04 -04:00
|
|
|
|
2016-08-14 07:29:35 -04:00
|
|
|
/**
|
|
|
|
* Register the service provider.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
2016-09-17 13:22:04 -04:00
|
|
|
Paginator::viewFactoryResolver(function () {
|
|
|
|
return $this->app['view'];
|
|
|
|
});
|
|
|
|
|
2016-08-14 07:29:35 -04:00
|
|
|
Paginator::currentPathResolver(function () {
|
2019-08-04 09:26:39 -04:00
|
|
|
return url($this->app['request']->path());
|
2016-08-14 07:29:35 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
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;
|
|
|
|
});
|
|
|
|
}
|
2018-01-28 11:58:52 -05:00
|
|
|
}
|