FilterScope::apply()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace Goopil\RestFilter\Scopes;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\Builder;
7
8
/**
9
 * Class FilterScope.
10
 */
11
class FilterScope extends BaseScope
12
{
13
    /**
14
     * @param Builder $builder
15
     * @param Model   $model
16
     *
17
     * @return Builder
18
     */
19
    public function apply(Builder $builder, Model $model)
20
    {
21
        $filter = $this->hasArray($this->request->get(config('queryScope.filter.param', 'filter'), null));
22
23
        if (count($filter) > 0) {
24
            $builder = $builder->select($filter);
0 ignored issues
show
Bug introduced by
The method select() does not exist on Illuminate\Database\Eloquent\Builder. Did you maybe mean createSelectWithConstraint()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
25
        }
26
27
        return $builder;
28
    }
29
}
30