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


PHP User::update方法代码示例

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


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

示例1: changePassword

 /**
  * Change the current users password.
  *
  * @param string $password The new password.
  * @param int $user_id The id of the user.
  *
  * @return boolean
  */
 public function changePassword($password, $user_id = null)
 {
     if ($user_id === null) {
         $user_id = $this->userId();
     }
     //if
     return $this->User->update(array('password' => \Crypt::hash($password)))->where('id=?', $user_id)->finalize();
 }
开发者ID:discophp,项目名称:project,代码行数:16,代码来源:User.php

示例2: save

 public function save()
 {
     $di = $this->getDi();
     $em = $di['doctrine']();
     $user = new User();
     $user->setEntityManager($em);
     $user->update();
     header('Location: /users');
 }
开发者ID:erikfig,项目名称:Curso-PHP-Moderno,代码行数:9,代码来源:UsersController.php

示例3: edit

 /**
  * Edit action method
  *
  * @return void
  */
 public function edit($id)
 {
     $user = new Model\User();
     $user->getById($id);
     if (!isset($user->id)) {
         $this->redirect('/users');
     }
     if ($this->services['acl']->isAllowed($this->sess->user->role, 'users-of-role-' . $user->role_id, 'edit')) {
         $this->prepareView('users/edit.phtml');
         $this->view->title = 'Edit User';
         $this->view->username = $user->username;
         $role = new Model\Role();
         $roles = $role->getAll();
         $roleValues = [];
         foreach ($roles as $r) {
             $roleValues[$r->id] = $r->name;
         }
         $fields = $this->application->config()['forms']['App\\Form\\User'];
         $fields[1]['username']['attributes']['onkeyup'] = 'pop.changeTitle(this.value);';
         $fields[1]['password1']['required'] = false;
         $fields[1]['password2']['required'] = false;
         $fields[0]['clear_logins']['value'][1] = $user->total_logins . ' Login' . ($user->total_logins == 1 ? '' : 's');
         $fields[0]['role_id']['type'] = 'select';
         $fields[0]['role_id']['label'] = 'Role';
         $fields[0]['role_id']['value'] = $roleValues;
         $fields[0]['role_id']['marked'] = $user->role_id;
         $this->view->form = new Form\User($fields);
         $this->view->form->addFilter('strip_tags', null, 'textarea')->addFilter('htmlentities', [ENT_QUOTES, 'UTF-8'])->setFieldValues($user->toArray());
         if ($this->request->isPost()) {
             $this->view->form->addFilter('strip_tags', null, 'textarea')->setFieldValues($this->request->getPost());
             if ($this->view->form->isValid()) {
                 $this->view->form->clearFilters()->addFilter('html_entity_decode', [ENT_QUOTES, 'UTF-8'])->filter();
                 $user = new Model\User();
                 $user->update($this->view->form->getFields(), $this->application->config()['application_title'], $this->sess);
                 $this->view->id = $user->id;
                 $this->sess->setRequestValue('saved', true);
                 $this->redirect('/users/edit/' . $user->id);
             }
         }
         $this->send();
     } else {
         $this->redirect('/users');
     }
 }
开发者ID:popphp,项目名称:pop-bootstrap,代码行数:49,代码来源:IndexController.php

示例4: password

 /**
  * Password action method
  *
  * @return void
  */
 public function password()
 {
     $roleId = $this->getRoleId();
     $user = new Model\User();
     $users = $user->getAll($roleId);
     $userIds = [];
     $this->console->append();
     $this->console->append("ID  \tUsername\tEmail");
     $this->console->append("----\t--------\t-----");
     foreach ($users as $user) {
         $userIds[] = $user->id;
         $this->console->append($user->id . "\t" . $user->username . "\t\t" . $user->email);
     }
     $this->console->append();
     $this->console->send();
     $userId = null;
     while (!is_numeric($userId) || !in_array($userId, $userIds)) {
         $userId = $this->console->prompt('Select User ID: ');
     }
     $password = '';
     while ($password == '') {
         $password = $this->console->prompt('Enter New Password: ');
     }
     $user = new Model\User();
     $user->update(['id' => $userId, 'role_id' => $roleId, 'password1' => $password], $this->application->config()['application_title']);
     $this->console->write();
     $this->console->write($this->console->colorize('User Password Updated!', Console::BOLD_GREEN));
 }
开发者ID:popphp,项目名称:pop-bootstrap,代码行数:33,代码来源:UsersController.php

示例5: update

 /**
  * Update the specified resource in storage.
  *
  * ps: Queue works when you have 3rd party service taking care for your jobs like Amazon SQS. 
  * Using Amazon SQS, you can queue mails, * jobs, etc. If 3rd party service is not configured, 
  * Laravel performs all command at the same time as a fail-safe.
  * 
  * @param  Illuminate\Http\Request $request
  * @param  App\Model\User $user
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, User $user)
 {
     $user->update($request->all());
     return $this->redirectWithSuccessFlash("user/{$user->id}/edit", "您已經更新了<b>{$user->username}</b>的資料");
 }
开发者ID:jocoonopa,项目名称:lubri,代码行数:16,代码来源:UserController.php

示例6: profile

 /**
  * Profile action method
  *
  * @return void
  */
 public function profile()
 {
     $this->prepareView('profile.phtml');
     $this->view->title = 'My Profile';
     $user = new Model\User();
     $user->getById($this->sess->user->id);
     $this->view->form = new Form\Profile($this->application->config()['forms']['App\\Form\\Profile']);
     $this->view->form->addFilter('htmlentities', [ENT_QUOTES, 'UTF-8'])->setFieldValues($user->toArray());
     if ($this->request->isPost()) {
         $this->view->form->addFilter('strip_tags')->setFieldValues($this->request->getPost());
         if ($this->view->form->isValid()) {
             $this->view->form->clearFilters()->addFilter('html_entity_decode', [ENT_QUOTES, 'UTF-8'])->filter();
             $user = new Model\User();
             $user->update($this->view->form->getFields(), $this->sess);
             $this->view->id = $user->id;
             $this->sess->setRequestValue('saved', true);
             $this->redirect('/profile');
         }
     }
     $this->send();
 }
开发者ID:popphp,项目名称:pop-bootstrap,代码行数:26,代码来源:IndexController.php

示例7: update

 public function update(User $user)
 {
     //验证表单
     $this->validate($this->request(), ['mobile' => 'required|digits:11', 'birthday' => 'required|date', 'sex' => 'required|in:' . array_keys_impload(UserEnum::$sexLang), 'password' => 'min:5|max:20', 'password_confirm' => 'required_with:password|same:password', 'marriage' => 'in:' . array_keys_impload(UserEnum::$marriageLang), 'height' => 'numeric|digits:3|min:130|max:210', 'education' => 'in:' . array_keys_impload(UserEnum::$educationLang), 'salary' => 'in:' . array_keys_impload(UserEnum::$salaryLang), 'user_name' => 'required|min:2|max:15']);
     $form = $this->request()->only(['sex', 'user_name', 'mobile', 'birthday', 'marriage', 'height', 'education', 'salary', 'work_province', 'work_city', 'level', 'house', 'children', 'realname', 'status']);
     if ($password = $this->request()->get('password')) {
         $form['password'] = $password;
     }
     $info = $this->request()->only(array('stock', 'origin_province', 'origin_city', 'introduce'));
     $object = $this->request()->get('object');
     try {
         transaction();
         $user->update($form);
         $user->info()->update($info);
         $user->object()->update($object);
         commit();
         return $this->redirect()->back()->withErrors(array('success' => '保存成功'));
     } catch (\Exception $e) {
         rollback();
     }
     return $this->redirect()->back()->withErrors(array('error' => '修改失败,请稍后再试'));
 }
开发者ID:netxinyi,项目名称:meigui,代码行数:22,代码来源:UserController.php


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