public function actionCreate($id)
 {
     $user = User::findOne($id);
     if (isset($user)) {
         $ent = new Entrepreneur();
         try {
             $ent->link('user', $user);
             $u = $ent->user;
             echo "ok id:{$id} name:{$u->username}\n";
         } catch (InvalidCallException $e) {
             echo $e->getMessage();
         }
     } else {
         echo "User id:{$id} not found";
     }
 }
Beispiel #2
0
 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new User();
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         if ($user->save()) {
             $profile = new Profile();
             $profile->loadDefaultValues();
             $profile->first_name = $this->first_name;
             $profile->last_name = $this->last_name;
             $profile->dob = $this->dob;
             $profile->address = $this->address;
             $profile->address2 = $this->address2;
             $profile->district = $this->district;
             $profile->state = $this->state;
             $profile->mobile = $this->mobile;
             $profile->ic = $this->ic;
             $profile->postcode = $this->postcode;
             $profile->name = $this->name;
             $profile->link('user', $user);
             if ($this->role == 'ENT') {
                 $ent = new Entrepreneur();
                 $ent->plkn = $this->plkn;
                 $ent->link('user', $user);
             } elseif ($this->role == 'MNT') {
                 $mnt = new Mentor();
                 $mnt->link('user', $user);
             }
             Yii::$app->mailer->compose()->setFrom('*****@*****.**')->setTo($user->email)->setSubject('SALEXES Registration')->setTextBody('Congratulations you have been succesfully registered with us !!!')->setHtmlBody('<b>Please contact admin@9teraju.com to make payment for account activation.</b>')->send();
             return $user;
         }
     }
     return null;
 }