本文整理匯總了PHP中common\models\User::setScenario方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::setScenario方法的具體用法?PHP User::setScenario怎麽用?PHP User::setScenario使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類common\models\User
的用法示例。
在下文中一共展示了User::setScenario方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionSignup
public function actionSignup()
{
$model = new User();
$model->setScenario('signup');
if ($model->load($_POST) && $model->save()) {
if (Yii::$app->getUser()->login($model)) {
$this->redirect('index');
}
}
return $this->render('signup', array('model' => $model));
}
示例2: actionSignup
public function actionSignup()
{
$model = new User();
$model->setScenario('signup');
if ($model->load($_POST) && $model->save()) {
if (Yii::$app->getUser()->login($model)) {
return $this->goHome();
}
}
return $this->render('signup', ['model' => $model]);
}
示例3: actionCreate
/**
* Creates a new User model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new User();
$model->setScenario('create_user');
if ($model->load(Yii::$app->request->post()) && $model->save()) {
$model->generatePasswordResetToken();
$model->save(false);
return $this->redirect(['view', 'id' => $model->id]);
}
$model->status = User::STATUS_ACTIVE;
$model->group = User::GROUP_READER;
return $this->render('create', ['model' => $model]);
}
示例4: signUp
/**
* Signs user up.
*
* @return User|null the saved model or null if saving fails
*/
public function signUp()
{
if ($this->validate(['username', 'password', 'confirm', 'email', 'mobile', 'group'])) {
if ($this->password !== $this->confirm) {
return null;
}
$user = new User();
$user->setScenario('register');
$user->username = $this->username;
$user->email = $this->email;
$user->mobile = $this->mobile;
$user->status = User::STATUS_ACTIVE;
$user->group = $this->group;
$user->changed_password = true;
$user->password_reset_token = Yii::$app->security->generateRandomString();
$user->setPassword($this->password);
$user->generateAuthKey();
if ($user->save()) {
return $user;
}
}
return null;
}
示例5: signup
/**
* Signs admin up.
*
* @return User|null the saved model or null if saving fails
*/
public function signup()
{
if ($this->validate()) {
$user = new User();
$user->setScenario("user-create");
// $user->username = $this->username;
$user->created_by = $this->email;
$user->modified_by = $this->email;
$user->email = $this->email;
$user->password = $this->password;
$user->repassword = $this->repassword;
$user->setPassword($this->password);
$user->generateAuthKey();
$user->first_name = $this->first_name;
$user->last_name = $this->last_name;
$user->mobile = $this->mobile;
$user->status = self::STATUS_INACTIVE;
$user->generateUserActivationCode();
if ($user->save()) {
return $user;
}
}
return null;
}