当前位置: 首页>>代码示例>>PHP>>正文


PHP Users::save方法代码示例

本文整理汇总了PHP中app\models\Users::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::save方法的具体用法?PHP Users::save怎么用?PHP Users::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Users的用法示例。


在下文中一共展示了Users::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionCreate

 /**
  * Creates a new Staff model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     if (Yii::$app->user->can('admin')) {
         $model = new Staff();
         if (Yii::$app->request->isAjax && $model->load($_POST)) {
             Yii::$app->response->format = 'json';
             return \yii\widgets\ActiveForm::validate($model);
         }
         if ($model->load(Yii::$app->request->post())) {
             $user = new Users();
             $user->usertype = 'Staff';
             $user->password = strtolower($model->apellido1 . substr($model->rut, 5, -2));
             $user->email = $model->correo;
             $model->save();
             $user->id_orig = $model->id;
             $user->username = $model->nombre . " " . $model->apellido1;
             $user->save();
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('create', ['model' => $model]);
         }
     } else {
         throw new ForbiddenHttpException();
     }
 }
开发者ID:godzukison,项目名称:mngrApp,代码行数:30,代码来源:StaffController.php

示例2: actionCreate

 /**
  * Creates a new Users model.
  * For ajax request will return json object
  * and for non-ajax request if creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $request = Yii::$app->request;
     $model = new Users();
     if ($request->isAjax) {
         /*
          *   Process for ajax request
          */
         Yii::$app->response->format = Response::FORMAT_JSON;
         if ($request->isGet) {
             return ['title' => "Create new Users", 'content' => $this->renderPartial('create', ['model' => $model]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['class' => 'btn btn-primary', 'type' => "submit"])];
         } else {
             if ($model->load($request->post()) && $model->save()) {
                 return ['forceReload' => 'true', 'title' => "Create new Users", 'content' => '<span class="text-success">Create Users success</span>', 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::a('Create More', ['create'], ['class' => 'btn btn-primary', 'role' => 'modal-remote'])];
             } else {
                 return ['title' => "Create new Users", 'content' => $this->renderPartial('create', ['model' => $model]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['class' => 'btn btn-primary', 'type' => "submit"])];
             }
         }
     } else {
         /*
          *   Process for non-ajax request
          */
         if ($model->load($request->post()) && $model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('create', ['model' => $model]);
         }
     }
 }
开发者ID:alfredosotil,项目名称:swinnapp,代码行数:35,代码来源:UsersController.php

示例3: actionCreate

 /**
  * Creates a new Users model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Users();
     $model->setScenario('register');
     $post = Yii::$app->request->post();
     $formName = basename($model->className());
     if ($model->load($post)) {
         // Default value
         $model->is_super_admin = isset($post[$formName]['is_super_admin']) ? $post[$formName]['is_super_admin'] : 0;
         $model->role = $model->is_super_admin ? Identity::ROLE_SUPERADMIN : 30;
         $model->fecha_conexion = isset($post[$formName]['fecha_conexion']) ? $post[$formName]['fecha_conexion'] : Yii::$app->fn->GetDate('none');
         $model->fecha_modif = isset($post[$formName]['fecha_modif']) ? $post[$formName]['fecha_modif'] : Yii::$app->fn->GetDate('none');
         $model->fecha_registro = isset($post[$formName]['fecha_registro']) ? $post[$formName]['fecha_registro'] : Yii::$app->fn->GetDate();
         $model->id_estado = isset($post[$formName]['id_estado']) ? $post[$formName]['id_estado'] : 1;
         if ($model->validate()) {
             $model->setPassword();
             $model->generateAuthKey();
             if ($model->save()) {
                 return $this->redirect(['view', 'id' => $model->id]);
             }
         }
     }
     // Load empty/error form
     return $this->render('create', ['model' => $model]);
 }
开发者ID:juanchi008,项目名称:playa_auto,代码行数:30,代码来源:UsersController.php

示例4: registerAction

 public function registerAction()
 {
     try {
         $form = new \RegisterForm();
         if ($this->request->isPost()) {
             $email = $this->request->getPost('email', 'email');
             $password = $this->request->getPost('password');
             $repeatPassword = $this->request->getPost('repeatPassword');
             $user = new Users();
             $user->setPassword($password, $repeatPassword);
             $user->email = $email;
             $user->created_at = new \Phalcon\Db\RawValue('now()');
             $user->user_name = $this->request->getPost('name', ['string', 'striptags']);
             $user->nickname = $this->request->getPost('nickname', 'string');
             if ($user->save() == false) {
                 foreach ($user->getMessages() as $message) {
                     $this->flash->error((string) $message);
                 }
             } else {
                 $this->tag->setDefault('email', '');
                 $this->tag->setDefault('password', '');
                 $this->auth->login($user->toArray());
                 $user->sendEmailAfterReg();
                 return $this->goToMain();
             }
         }
     } catch (\Exception $e) {
         $this->flash->error($e->getMessage());
     }
     $this->view->form = $form;
 }
开发者ID:kofeinstyle,项目名称:coc,代码行数:31,代码来源:UserController.php

示例5: indexAction

 /**
  * Action to register a new user
  */
 public function indexAction()
 {
     $form = new RegisterForm();
     if ($this->request->isPost()) {
         $name = $this->request->getPost('name', array('string', 'striptags'));
         $username = $this->request->getPost('username', 'alphanum');
         $email = $this->request->getPost('email', 'email');
         $password = $this->request->getPost('password');
         $repeatPassword = $this->request->getPost('repeatPassword');
         if ($password != $repeatPassword) {
             $this->flash->error('Passwords are different');
             return false;
         }
         $user = new Users();
         $user->username = $username;
         $user->password = sha1($password);
         $user->name = $name;
         $user->email = $email;
         $user->created_at = new \Phalcon\Db\RawValue('now()');
         $user->active = 'Y';
         if ($user->save() == false) {
             foreach ($user->getMessages() as $message) {
                 $this->flash->error((string) $message);
             }
         } else {
             $this->tag->setDefault('email', '');
             $this->tag->setDefault('password', '');
             $this->flash->success('Thanks for sign-up, please log-in to start generating invoices');
             return $this->forward('session/index');
         }
     }
     $this->view->form = $form;
 }
开发者ID:kenikori,项目名称:phalcon2_invo,代码行数:36,代码来源:RegisterController.php

示例6: prosesAdd

 /**
  * 
  * @return Redirect
  */
 public function prosesAdd()
 {
     $rules = ['username' => 'required', 'password' => 'required', 'email' => 'required|email'];
     $validator = Validator::make(Input::all(), $rules);
     /*
      * jika tidak valid redirect kembali ke halaman create
      */
     if ($validator->fails()) {
         return Redirect::to('/users/add')->withErrors($validator);
     } else {
         /*
          * jika valid simpan ke database
          */
         $in = Input::all();
         $pass = $in['password'];
         $pass = Crypt::encrypt($pass);
         $user = new Users();
         $user->username = $in['username'];
         $user->password = $pass;
         $user->email = $in['email'];
         $user->save();
         /*
          * redirect ke index bands
          */
         Session::flash('message', 'Successfully created band!');
         return Redirect::to('/users');
     }
 }
开发者ID:CBEPX,项目名称:laravel-mikrotik,代码行数:32,代码来源:UserController.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     if ($request->userID) {
         $user = Users::where("uID", $request->userID)->first();
         if ($request->password) {
             $user->uPassword = md5($request->password);
         }
     } else {
         $user = new Users();
         $user->uPassword = md5($request->password);
         $user->uRegisteredDate = date('Y-m-d');
         $user->uIsActive = 1;
         $user->uRole = 1;
         $user->uUsername = $request->username;
         $user->uEmail = $request->email;
     }
     $user->uBirthday = date('Y-m-d', strtotime($request->birthday));
     $user->uAddress = $request->address;
     $user->uPhone = $request->phone;
     $file = Input::file('image');
     // $file->getRealPath()
     if (!is_null($file)) {
         $destinationPath = public_path() . '/assets/images/avatar/';
         $fileName = explode(".", $file->getClientOriginalName())[0];
         $fileName = $fileName . rand(1, 9999) . "." . $file->getClientOriginalExtension();
         Input::file('image')->move($destinationPath, $fileName);
         Image::make($destinationPath . $fileName)->resize(400, 400)->save($destinationPath . '400x400/' . $fileName);
         $user->uAvatar = $fileName;
     }
     $user->save();
     return Redirect::action('admin\\user@index');
 }
开发者ID:NguyenHoangThien,项目名称:learningBlog,代码行数:38,代码来源:user.php

示例8: actionReg

 public function actionReg()
 {
     $model = new RegForm();
     $error = null;
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $user = new Users();
         $user->login = Html::encode($model->login);
         $user->password = md5($model->password);
         $user->name = Html::encode($model->name);
         $user->email = Html::encode($model->email);
         $user->phone = Html::encode($model->phone);
         if (UploadedFile::getInstance($model, 'photo')) {
             $model->photo = UploadedFile::getInstance($model, 'photo');
             $model->photo->saveAs('img/photo/' . $model->photo->baseName . '.' . $model->photo->extension);
             $photo = 'img/photo/' . $model->photo->baseName . '.' . $model->photo->extension;
             $user->photo = $photo;
         }
         $uc = new UserClass();
         if ($uc->isUniqueLogin($user->login)) {
             $user->save();
             return $this->render('regsuccess');
         } else {
             $error = 'Такой логин уже существует';
         }
     }
     return $this->render('reg', ['model' => $model, 'error' => $error]);
 }
开发者ID:siegigor,项目名称:shopheadphones,代码行数:27,代码来源:UserController.php

示例9: userInfo

 public function userInfo($userInfo)
 {
     print_r($userInfo);
     $user = new Users();
     $user->email = $userInfo['email'];
     $user->name = $userInfo['name'];
     $user->save();
 }
开发者ID:nixwins,项目名称:microframework,代码行数:8,代码来源:old_Controller.php

示例10: saveAction

 public function saveAction()
 {
     if (!$this->isXmlHttpRequest()) {
         throw new \Exception('Неверный тип запроса!');
     }
     $usersModel = new Users();
     $data = $this->request->getPost();
     if (!isset($data['id']) || !isset($data['roles_id']) || !isset($data['user']) || !isset($data['password'])) {
         throw new \Exception('Неверный тип запроса!');
     }
     if ($data['action'] == 'add' && (!isset($data['lastname']) || !isset($data['firstname']) || !isset($data['secondname']) || !isset($data['org_name']))) {
         throw new \Exception('Неверный тип запроса!');
     }
     $data['id'] = (int) $data['id'];
     if (!$data['id'] && $data['action'] != 'add') {
         throw new \Exception('Неверный идентификатор пользователя!');
     }
     $data['roles_id'] = (int) $data['roles_id'];
     if ($data['roles_id'] == 0) {
         throw new \Exception('Не выбраны права пользователя!');
     }
     $data['user'] = trim($data['user']);
     if ($data['user'] == '') {
         throw new \Exception('Не заполнено обязательное поле Email!');
     }
     $data['password'] = trim($data['password']);
     if ($data['password'] == '' && $data['action'] != 'add') {
         unset($data['password']);
     }
     if (isset($data['password']) && mb_strlen($data['password']) < 6) {
         throw new \Exception('Пароль должен быть больше 6 символов!');
     }
     if ($data['action'] == 'add') {
         $data['lastname'] = trim($data['lastname']);
         if ($data['lastname'] == '') {
             throw new \Exception('Не заполнено обязательное поле Фамилия!');
         }
         $data['firstname'] = trim($data['firstname']);
         if ($data['firstname'] == '') {
             throw new \Exception('Не заполнено обязательное поле Имя!');
         }
         $data['secondname'] = trim($data['secondname']);
         if ($data['secondname'] == '') {
             throw new \Exception('Не заполнено обязательное поле Отчество!');
         }
         $data['org_name'] = trim($data['org_name']);
         if ($data['org_name'] == '') {
             throw new \Exception('Не заполнено обязательное поле Организация!');
         }
     }
     unset($data['action']);
     $data['id'] = $usersModel->save($data);
     $usersModel->setWhere(array('id' => $data['id']));
     $uData = $usersModel->select();
     $this->view->data = $uData[0];
     $rolesModel = new Roles();
     $this->view->roles = $rolesModel->select();
 }
开发者ID:BoesesGenie,项目名称:team-rex,代码行数:58,代码来源:UsersController.php

示例11: actionRegistration

 public function actionRegistration()
 {
     $model = new Users();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['site/index']);
     } else {
         return $this->render('registration', ['model' => $model]);
     }
 }
开发者ID:egrubbi,项目名称:project,代码行数:9,代码来源:UsersController.php

示例12: actionCreate

 /**
  * Creates a new Users model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Users();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->user . id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:Herklos,项目名称:Your-Corp,代码行数:14,代码来源:UserController.php

示例13: setUp

 protected function setUp()
 {
     $_SERVER['REQUEST_URI'] = 'index.php';
     parent::setUp();
     $this->controllerSite = \Yii::$app->createControllerByID('site');
     $user = new Users();
     $user->username = $user->password = 'root';
     $user->save();
 }
开发者ID:yurii-github,项目名称:yii2-mylib,代码行数:9,代码来源:AuthenticationTest.php

示例14: reg

 public function reg()
 {
     $user = new Users();
     $user->username = $this->username;
     $user->setPassword($this->password);
     $user->generateAuthKey();
     $user->save();
     return $user;
 }
开发者ID:eropkinvitaliy,项目名称:tech-admin,代码行数:9,代码来源:RegForm.php

示例15: insertUser

 public function insertUser($insert_user)
 {
     $user = new Users();
     $user->username = $insert_user['username'];
     $user->password = $insert_user['password'];
     $user->permission = $insert_user['permission'];
     $user->name = $insert_user['name'];
     $user->pmail = $insert_user['pmail'];
     $user->save();
 }
开发者ID:houzhenggang,项目名称:EmailManager,代码行数:10,代码来源:Users.php


注:本文中的app\models\Users::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。