本文整理匯總了PHP中common\models\User::createUser方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::createUser方法的具體用法?PHP User::createUser怎麽用?PHP User::createUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類common\models\User
的用法示例。
在下文中一共展示了User::createUser方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionCreate
/**
* Creates a new Client model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Client();
$userModel = new User();
if (Yii::$app->request->isAjax && $userModel->load(Yii::$app->request->post())) {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($userModel);
}
if ($model->load(Yii::$app->request->post()) && $userModel->load(Yii::$app->request->post())) {
$arr = ['User' => $_POST['User'], 'Client' => $_POST['Client']];
$result = User::createUser($this->_roleId, $arr);
if ($result) {
return $this->redirect(['index']);
} else {
return $this->render('create', ['model' => $model, 'userModel' => $userModel]);
}
} else {
return $this->render('create', ['model' => $model, 'userModel' => $userModel]);
}
}
示例2: actionCreate
public function actionCreate()
{
$model = new Client();
$userModel = new User();
//validate email unique
if (Yii::$app->request->isAjax && $userModel->load(Yii::$app->request->post())) {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($userModel);
}
// $group = Advisor::findGroupByAdvisor($this->user->id_extend);
if ($model->load(Yii::$app->request->post())) {
$user = User::createUser(Dict::USER_ROLE_CLIENT, ['User' => Yii::$app->request->post('User'), 'Client' => Yii::$app->request->post('Client')]);
if ($user) {
return $this->redirect(['index']);
}
} else {
return $this->render('create', ['model' => $model, 'userModel' => $userModel]);
}
}
示例3: actionCreate
/**
* Creates a new Application model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Application();
$appModel = new AppApplicant(['scenario' => 'primary-create']);
$coAppModel = new AppApplicant(['scenario' => 'co-create']);
$appFormModel = new AppForm();
//加載數據並驗證
if ($model->load(Yii::$app->request->post()) && $appModel->load(Yii::$app->request->post()) && $coAppModel->load(Yii::$app->request->post()) && $appFormModel->load(Yii::$app->request->post()) && $model->validate() && $appModel->validate() && ($model->is_joint_application == 1 ? $coAppModel->validate() : true) && ($model->is_joint_application == 1 ? $appModel->email_address != $coAppModel->email_address : true)) {
//開啟事務
$transaction = Yii::$app->db->beginTransaction();
try {
if (!$appModel->id_user) {
$user = User::createUser(Dict::USER_ROLE_CLIENT, ['User' => ['first_name' => $appModel->first_name, 'last_name' => $appModel->last_name, 'mid_name' => $appModel->mid_name, 'email' => $appModel->email_address], 'Client' => ['id_group' => $model->id_group]]);
//設置applicant的id_user
$appModel->id_user = $user->id_user;
SendEmail::email(DictEmail::EMAIL_INVITE_USER, [$user]);
}
if ($model->is_joint_application && !$coAppModel->id_user) {
$user = User::createUser(Dict::USER_ROLE_CLIENT, ['User' => ['first_name' => $coAppModel->first_name, 'last_name' => $coAppModel->last_name, 'mid_name' => $coAppModel->mid_name, 'email' => $coAppModel->email_address], 'Client' => ['id_group' => $model->id_group]]);
//設置co-applicant的id_user
$coAppModel->id_user = $user->id_user;
SendEmail::email(DictEmail::EMAIL_INVITE_USER, [$user]);
}
$model->application_name = $appModel->first_name . ($model->is_joint_application ? ' and ' . $coAppModel->first_name : '') . "'s application";
$model->charge_fee = Advisor::findOne(['id_user' => Yii::$app->user->getId()])->will_charge_fee;
if (!$model->save()) {
$transaction->rollBack();
}
$user = Yii::$app->user->getIdentity();
Active::operationLog($model->id_application, [$user->first_name, $user->last_name], DictActive::CREATE_APPLICATION, $user->id);
$appModel->id_application = $model->id_application;
$appModel->id_app_applicant_type = 1;
if (!$appModel->save()) {
$transaction->rollBack();
}
if ($model->is_joint_application == 1) {
$coAppModel->id_application = $model->id_application;
$coAppModel->id_app_applicant_type = 2;
if (!$coAppModel->save()) {
$transaction->rollBack();
}
}
$appFormModel->id_application = $model->id_application;
if (!$appFormModel->save()) {
$transaction->rollBack();
}
//初始化任務
AppTask::initialize($model->id_application);
// 將AppTaskCheckpoint中的模板轉換為實例
AppTaskCheckpoint::initialize($model->appTask);
//創建AppUser記錄
AppUser::createByApplication($model);
//send email to notificate advisor create application success.method email([$task_type,$id_application,$id_app_owner_task],$notify_type)
SendEmail::email(DictEmail::EMAIL_TASK_NOTIFICATION, [DictTask::TYPE_APPLICATION_FORM, $model->id_application, 0]);
//id_app_owner_task_type:1(app-form);0:表示沒有傳遞id_app_owner_task
$transaction->commit();
} catch (Exception $e) {
$transaction->rollBack();
}
return $this->redirect(['/app-form/basic-info', 'id_application' => $model->id_application]);
}
return $this->render('create', ['model' => $model, 'appModel' => $appModel, 'coAppModel' => $coAppModel, 'appFormModel' => $appFormModel]);
}
示例4: actionAddAdvisor
/**
* add advisor
*/
public function actionAddAdvisor($id = null)
{
$model = new Advisor();
$userModel = new User();
//validate email unique
if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post()) && $userModel->load(Yii::$app->request->post())) {
Yii::$app->response->format = Response::FORMAT_JSON;
return array_merge(ActiveForm::validate($userModel), ActiveForm::validate($model));
}
if ($model->load(Yii::$app->request->get()) && $userModel->load(Yii::$app->request->get())) {
Yii::$app->response->format = Response::FORMAT_JSON;
$user = User::createUser(Dict::USER_ROLE_ADVISOR, ['User' => $_GET['User'], 'Advisor' => $_GET['Advisor']]);
if ($user) {
if (!empty($id)) {
$advisorGroup = new AdvisorGroup();
$advisorGroup->id_group = $id;
$advisorGroup->id_advisor = $user->advisor->id_advisor;
$advisorGroup->save();
}
return true;
} else {
return false;
}
}
return $this->renderAjax('add_advisor', ['model' => $model, 'user' => $userModel, 'id' => $id]);
}