/** * @param string $email * @param string $username * @return mixed */ public function create($email, $username) { $model = User::find()->where(['email' => $email])->one(); if (!$model) { $model = new User(); $model->email = $email; $model->username = $username; if ($model->save()) { return $model; } return null; } return $model; }