Conditions | 6 |
Paths | 6 |
Total Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
19 | public function apply(Builder $builder, Model $model) |
||
20 | { |
||
21 | $hasLimit = false; |
||
22 | |||
23 | $limitKey = config('queryScope.offsetLimit.limitParam', 'limit'); |
||
24 | if ($this->request->has($limitKey)) { |
||
25 | $value = $this->request->get($limitKey); |
||
26 | $builder = $builder->limit(is_int($value) ? $value : 15); |
||
27 | $hasLimit = true; |
||
28 | } |
||
29 | |||
30 | $offsetKey = config('queryScope.offsetLimit.offsetParam', 'offset'); |
||
31 | if ($this->request->has($offsetKey)) { |
||
32 | $value = $this->request->get($offsetKey); |
||
33 | $builder = $builder->offset(is_int($value) ? $value : 0); |
||
34 | |||
35 | /* |
||
36 | * nasty work around ... |
||
37 | * @see https://github.com/laravel/framework/issues/5458 |
||
38 | */ |
||
39 | if ($hasLimit === false) { |
||
40 | $builder = $builder->limit(PHP_INT_MAX); |
||
41 | } |
||
42 | } |
||
43 | |||
44 | return $builder; |
||
45 | } |
||
46 | } |
||
47 |