StatusFilterQuery::handle()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 14
c 1
b 0
f 0
rs 9.2
cc 4
eloc 7
nc 8
nop 2
1
<?php namespace Anomaly\UsersModule\User\Table\Filter;
2
3
use Anomaly\Streams\Platform\Ui\Table\Component\Filter\Contract\FilterInterface;
4
use Anomaly\Streams\Platform\Ui\Table\Component\Filter\Query\GenericFilterQuery;
5
use Illuminate\Database\Eloquent\Builder;
6
7
/**
8
 * Class StatusFilterQuery
9
 *
10
 * @link          http://pyrocms.com/
11
 * @author        PyroCMS, Inc. <[email protected]>
12
 * @author        Ryan Thompson <[email protected]>
13
 */
14
class StatusFilterQuery extends GenericFilterQuery
15
{
16
17
    /**
18
     * Handle the filter query.
19
     *
20
     * @param Builder         $query
21
     * @param FilterInterface $filter
22
     */
23
    public function handle(Builder $query, FilterInterface $filter)
24
    {
25
        if ($filter->getValue() == 'active') {
26
            $query->where('enabled', true)->where('activated', true);
27
        }
28
29
        if ($filter->getValue() == 'inactive') {
30
            $query->where('enabled', true)->where('activated', false);
31
        }
32
33
        if ($filter->getValue() == 'disabled') {
34
            $query->where('enabled', false);
35
        }
36
    }
37
}
38