public function getUser() { if ($this->_user === false) { $this->_user = \account\models\User::findByEmail($this->email); } return $this->_user; }
public function actionIndex() { $model = new User(); $model->scenario = 'register'; if (Yii::$app->request->post('Register')) { $model->attributes = Yii::$app->request->post('Register'); if ($model->validate()) { $model->encodePassword(); $save = $model->save(); if ($save) { Yii::$app->mail->compose('Registrierung', 'Sie haben sich erfolgreich registriert.<br />E-Mail: ' . $model->email . '<br />Passwort: ' . $model->plainPassword . '<br /><br />Sie können Sich nun einloggen.')->address($model->email)->send(); } } } return $this->render('index', ['model' => $model, 'errors' => $model->getErrors(), 'save' => isset($save) ? $save : false]); }