1 | <?php |
||
2 | |||
3 | namespace Spatie\JsonApiPaginate; |
||
4 | |||
5 | use Illuminate\Database\Eloquent\Builder; |
||
6 | use Illuminate\Support\Arr; |
||
7 | use Illuminate\Support\ServiceProvider; |
||
8 | |||
9 | class JsonApiPaginateServiceProvider extends ServiceProvider |
||
10 | { |
||
11 | public function boot() |
||
12 | { |
||
13 | if ($this->app->runningInConsole()) { |
||
14 | $this->publishes([ |
||
15 | __DIR__.'/../config/json-api-paginate.php' => config_path('json-api-paginate.php'), |
||
16 | ], 'config'); |
||
17 | } |
||
18 | |||
19 | $this->registerMacro(); |
||
20 | } |
||
21 | |||
22 | public function register() |
||
23 | { |
||
24 | $this->mergeConfigFrom(__DIR__.'/../config/json-api-paginate.php', 'json-api-paginate'); |
||
25 | } |
||
26 | |||
27 | protected function registerMacro() |
||
28 | { |
||
29 | Builder::macro(config('json-api-paginate.method_name'), function (int $maxResults = null, int $defaultSize = null) { |
||
30 | $maxResults = $maxResults ?? config('json-api-paginate.max_results'); |
||
31 | $defaultSize = $defaultSize ?? config('json-api-paginate.default_size'); |
||
32 | $numberParameter = config('json-api-paginate.number_parameter'); |
||
33 | $sizeParameter = config('json-api-paginate.size_parameter'); |
||
34 | $paginationParameter = config('json-api-paginate.pagination_parameter'); |
||
35 | |||
36 | $size = (int) request()->input($paginationParameter.'.'.$sizeParameter, $defaultSize); |
||
37 | |||
38 | $size = $size > $maxResults ? $maxResults : $size; |
||
39 | |||
40 | $paginator = $this |
||
41 | ->paginate($size, ['*'], $paginationParameter.'.'.$numberParameter) |
||
0 ignored issues
–
show
|
|||
42 | ->setPageName($paginationParameter.'['.$numberParameter.']') |
||
43 | ->appends(Arr::except(request()->input(), $paginationParameter.'.'.$numberParameter)); |
||
44 | |||
45 | if (! is_null(config('json-api-paginate.base_url'))) { |
||
46 | $paginator->setPath(config('json-api-paginate.base_url')); |
||
47 | } |
||
48 | |||
49 | return $paginator; |
||
50 | }); |
||
51 | } |
||
52 | } |
||
53 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.