StatusFilterQuery   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 24
c 1
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 14 4
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