/** * 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(); $user->status = 0; if ($user->save()) { $notification = new Notification(); $notification->title = 'user'; $notification->message = 'new user, username:'******'model' => 'User', 'id' => $user->id]); if ($notification->save()) { $this->sendEmail($this->email); } else { print_r($notification->getErrors()); exit(0); } return $user; } else { return $user->getErrors(); } } return null; }