本文整理汇总了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);
}