| 1 | <?php |
||
| 16 | class UserQuery extends ActiveQuery |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @param $usernameOrEmail |
||
| 20 | * |
||
| 21 | * @return $this |
||
| 22 | */ |
||
| 23 | 4 | public function whereUsernameOrEmail($usernameOrEmail) |
|
| 24 | { |
||
| 25 | 4 | return filter_var($usernameOrEmail, FILTER_VALIDATE_EMAIL) |
|
| 26 | 4 | ? $this->whereEmail($usernameOrEmail) |
|
| 27 | 4 | : $this->whereUsername($usernameOrEmail); |
|
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @param $email |
||
| 32 | * |
||
| 33 | * @return $this |
||
| 34 | */ |
||
| 35 | 5 | public function whereEmail($email) |
|
| 36 | { |
||
| 37 | 5 | return $this->andWhere(['email' => $email]); |
|
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @param $username |
||
| 42 | * |
||
| 43 | * @return $this |
||
| 44 | */ |
||
| 45 | 1 | public function whereUsername($username) |
|
| 46 | { |
||
| 47 | 1 | return $this->andWhere(['username' => $username]); |
|
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @param $id |
||
| 52 | * |
||
| 53 | * @return $this |
||
| 54 | */ |
||
| 55 | 1 | public function whereId($id) |
|
| 59 | |||
| 60 | /** |
||
| 61 | * @param $id |
||
| 62 | * |
||
| 63 | * @return $this |
||
| 64 | */ |
||
| 65 | public function whereNotId($id) |
||
| 69 | } |
||
| 70 |