/** * 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(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * 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->scenario = User::SCENARIO_CREATE_USER; $model->status = User::STATUS_ACTIVE; if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Category model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new User(); if ($model->load(Yii::$app->request->post()) && $model->save()) { if ($model->role == 'admin') { $auth = Yii::$app->authManager; $auth->assign($auth->getRole('admin'), $model->id); } return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model]); } }
/** * 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(); $profile = new Profile(); if ($model->load(Yii::$app->request->post()) && $model->save()) { $profile->user_id = $model->id; $profile->name = $model->name; $profile->save(false); return $this->redirect(['update', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
public function run() { $model = new User(); $model->scenario = User::SCENARIO_UPDATE_USER; if ($model->load(Yii::$app->request->post()) && $model->save()) { $auth = Yii::$app->authManager; $role = $auth->getRole($this->role); $auth->assign($role, $model->getId()); return $this->controller->redirect([$this->redirectAction]); } else { return $this->controller->render($this->view, ['model' => $model]); } }
public function actionCreateAdmin() { $this->isSuperAdmin(); $model = new User(); $model->scenario = User::SCENARIO_CREATE_ADMIN; $model->status = User::STATUS_ACTIVE; $model->role = 1; if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->session->setFlash('success', 'Новый администратор успешно добавлен в систему'); return $this->redirect(['administrators']); } else { return $this->render('createAdmin', ['model' => $model]); } }
public function actionCreateClient() { $model = new User(); $model->scenario = User::SCENARIO_CREATE_USER; $model->status = User::STATUS_ACTIVE; if ($model->load(Yii::$app->request->post()) && $model->save()) { $auth = Yii::$app->authManager; $role = $auth->getRole('client'); $auth->assign($role, $model->getId()); return $this->redirect(['create-client-profile', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }