]> BookStack Code Mirror - bookstack/blob - app/Providers/PaginationServiceProvider.php
Replaced use of custom 'baseUrl' helper with 'url'
[bookstack] / app / Providers / PaginationServiceProvider.php
1 <?php namespace BookStack\Providers;
2
3 use Illuminate\Pagination\PaginationServiceProvider as IlluminatePaginationServiceProvider;
4 use Illuminate\Pagination\Paginator;
5
6 class PaginationServiceProvider extends IlluminatePaginationServiceProvider
7 {
8
9     /**
10      * Register the service provider.
11      *
12      * @return void
13      */
14     public function register()
15     {
16         Paginator::viewFactoryResolver(function () {
17             return $this->app['view'];
18         });
19
20         Paginator::currentPathResolver(function () {
21             return url($this->app['request']->path());
22         });
23
24         Paginator::currentPageResolver(function ($pageName = 'page') {
25             $page = $this->app['request']->input($pageName);
26
27             if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) {
28                 return $page;
29             }
30
31             return 1;
32         });
33     }
34 }