public function register() { if (!$this->validate()) { return false; } $user = new User(['username' => $this->username, 'password' => $this->password]); $profile = $user->create(Profile::className(), ['nickname' => $this->username, 'display_name' => $this->username]); $email = $user->create(Email::className(), ['email' => $this->email]); return $user->register([$profile, $email]); }
/** * @return \yii\db\ActiveQuery */ public function getEmails() { $email = Email::buildNoInitModel(); return $this->hasMany(Email::className(), [$email->createdByAttribute => $this->guidAttribute])->inverseOf('user'); }