Completed
Push — master ( c22208...64acfb )
by Igor
04:17
created

UserQuery::like()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace app\models\query;
4
5
use Yii;
6
use yii\db\ActiveQuery;
7
use app\models\User;
8
9
/**
10
 * ActiveQuery for User
11
 */
12
class UserQuery extends ActiveQuery
13
{
14
    /**
15
     * Select only active
16
     *
17
     * @return yii\db\ActiveQuery
18
     */
19
    public function active()
20
    {
21
        $this->andWhere(['status' => User::STATUS_ACTIVE]);
22
        return $this;
23
    }
24
25
    /**
26
     * Select only blocked
27
     *
28
     * @return yii\db\ActiveQuery
29
     */
30
    public function blocked()
31
    {
32
        $this->andWhere(['status' => User::STATUS_BLOCKED]);
33
        return $this;
34
    }
35
36
    /**
37
     * Select only deleted
38
     *
39
     * @return yii\db\ActiveQuery
40
     */
41
    public function deleted()
42
    {
43
        $this->andWhere(['status' => User::STATUS_DELETED]);
44
        return $this;
45
    }
46
47
    /**
48
     * `Like` search for value in the field
49
     *
50
     * @param string $field
51
     * @param string $value
52
     * @return yii\db\ActiveQuery
53
     */
54
    public function like($field, $value)
55
    {
56
        $this->andWhere(['like', $field, $value]);
57
        return $this;
58
    }
59
}
60