/**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $transaction = Yii::$app->db->beginTransaction();
         // Create the user
         $user = new User(['username' => $this->username, 'email' => $this->email, 'password_hash' => Yii::$app->security->generatePasswordHash($this->password), 'auth_key' => Yii::$app->security->generateRandomString(), 'scope' => User::SCOPE_FRONTEND, 'confirmed_at' => time()]);
         if ($user->save()) {
             // Create the profile
             $profile = new Profile(['user_id' => $user->id, 'name' => $this->name, 'public_email' => $this->email, 'firstname' => $this->firstname, 'address' => $this->address, 'city' => $this->city, 'zipcode' => $this->zipcode, 'phone' => $this->phone, 'mobile' => $this->mobile, 'language' => $this->language]);
             if ($profile->save(false)) {
                 $transaction->commit();
                 return $user;
             }
         }
     }
     return null;
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProfile()
 {
     return $this->hasOne(Profile::className(), ['user_id' => 'id']);
 }