本文整理匯總了PHP中backend\models\User::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::create方法的具體用法?PHP User::create怎麽用?PHP User::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類backend\models\User
的用法示例。
在下文中一共展示了User::create方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionCreate
/**
* Creates a new User model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$username = Yii::$app->user->identity->username;
$model = new User();
$model->scenario = 'create';
if (Yii::$app->request->isPost && ($model = User::create(Yii::$app->request->post()))) {
return $this->redirect(['update', 'id' => $model->id]);
} else {
return $this->render('create', ['username' => $username, 'model' => $model]);
}
}
示例2: newDemoUser
/**
* Set up a new demo user and log in.
*
* @return BackendAuth
*/
protected function newDemoUser()
{
$demoManager = DemoManager::instance();
$login = Str::quickRandom(Config::get('krisawzm.demomanager::username_length', 10));
if (!$demoManager->copyTheme($login)) {
return false;
}
$user = User::create(['email' => $login . '@' . $login . '.tld', 'login' => $login, 'password' => $login, 'password_confirmation' => $login, 'first_name' => ucfirst($login), 'last_name' => 'Demo', 'permissions' => $this->getPermissions(), 'is_activated' => true]);
BackendAuth::login($user);
UserCounter::instance()->inc();
return $user;
}
示例3: run
public function run()
{
$group = UserGroup::create(['name' => 'Owners', 'code' => UserGroup::DEFAULT_CODE, 'description' => 'Default group for website owners.', 'is_new_user_default' => false]);
$user = User::create(['email' => static::$email, 'login' => static::$login, 'password' => static::$password, 'password_confirmation' => static::$password, 'first_name' => static::$firstName, 'last_name' => static::$lastName, 'permissions' => ['superuser' => 1], 'is_activated' => true]);
$user->addGroup($group);
}
示例4: run
public function run()
{
$group = UserGroup::create(['name' => 'Admins', 'code' => 'admins', 'description' => 'Default group for administrators', 'is_new_user_default' => true]);
$user = User::create(['email' => static::$email, 'login' => static::$login, 'password' => static::$password, 'password_confirmation' => static::$password, 'first_name' => static::$firstName, 'last_name' => static::$lastName, 'permissions' => ['superuser' => 1], 'is_activated' => true]);
$user->addGroup($group);
}
示例5: insertUser
/**
* @param array $data
* @return int
*/
public function insertUser($data)
{
$user = User::create($data);
return $user->id;
}
示例6: run
public function run()
{
$group = UserGroup::create(['name' => 'Admins']);
$user = User::create(['email' => static::$email, 'login' => static::$login, 'password' => static::$password, 'password_confirmation' => static::$password, 'first_name' => static::$firstName, 'last_name' => static::$lastName, 'permissions' => ['superuser' => 1], 'is_activated' => true]);
$user->addGroup($group);
}