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


PHP UserRepository::save方法代码示例

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


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

示例1: handleSave

 public function handleSave(Form $form)
 {
     $values = $form->values;
     if ($values['file']->isOk()) {
         if ($values['cleanout']) {
             foreach ($this->userRepository->findAll() as $user) {
                 $this->userRepository->delete($user);
             }
         }
         /** @var FileUpload $file */
         $file = $values['file'];
         $data = file_get_contents($file->getTemporaryFile());
         foreach (explode("\n", $data) as $row) {
             if (!$row) {
                 continue;
             }
             $items = explode(',', $row);
             if (!count($items)) {
                 continue;
             }
             try {
                 $user = new UserEntity(trim($items[0]));
             } catch (InvalidArgumentException $e) {
                 $form->addError($e->getMessage());
             }
             $this->userRepository->save($user);
         }
     }
 }
开发者ID:venne,项目名称:newsletter-module,代码行数:29,代码来源:ImportFormFactory.php

示例2: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @param  UserRequest  $request
  * @return Response
  */
 public function update($id, UserRequest $request)
 {
     $data = $request->has('password') ? $request->all() : $request->except('password');
     $this->user->save($id, $data);
     $route = $request->get('task') == 'apply' ? route('admin.users.edit', $id) : route('admin.users.index');
     return redirect($route)->with(['status' => trans('messages.saved'), 'type-status' => 'success']);
 }
开发者ID:wyrover,项目名称:backendl5,代码行数:14,代码来源:UsersController.php

示例3: postEdit

 /**
  * Edits a user
  * @var User
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postEdit(User $user)
 {
     $oldUser = clone $user;
     $user->username = Input::get('username');
     $user->email = Input::get('email');
     $user->phone_number = Input::get('phone_number');
     $password = Input::get('password');
     $passwordConfirmation = Input::get('password_confirmation');
     if (!empty($password)) {
         if ($password != $passwordConfirmation) {
             // Redirect to the new user page
             $error = Lang::get('admin/users/messages.password_does_not_match');
             return Redirect::to('user')->with('error', $error);
         } else {
             $user->password = $password;
             $user->password_confirmation = $passwordConfirmation;
         }
     }
     $data = array('city_id' => Input::get('city_id'), 'address' => Input::get('address'));
     if ($user->address_id) {
         Address::where('id', $user->address_id)->update($data);
     } else {
         $address = Address::create($data);
         $user['address_id'] = $address->id;
     }
     if ($this->userRepo->save($user)) {
         return Redirect::to('user/profile/' . $user->username)->with('success', Lang::get('user/user.user_account_updated'));
     } else {
         $error = $user->errors()->all(':message');
         return Redirect::to('user')->withInput(Input::except('password', 'password_confirmation'))->with('error', $error);
     }
 }
开发者ID:EricBui0512,项目名称:FYP,代码行数:37,代码来源:UserController.php

示例4: postEdit

 /**
  * Edits a user
  * @var User
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postEdit(User $user)
 {
     $oldUser = clone $user;
     $user->username = Input::get('username');
     $user->email = Input::get('email');
     $password = Input::get('password');
     $passwordConfirmation = Input::get('password_confirmation');
     if (!empty($password)) {
         if ($password != $passwordConfirmation) {
             $error = Lang::get('admin/users/messages.password_does_not_match');
             return Redirect::to('user')->with('error', $error);
         } else {
             $user->password = $password;
             $user->password_confirmation = $passwordConfirmation;
         }
     }
     if ($this->userRepo->save($user)) {
         return Redirect::to('user')->with('success', Lang::get('user/user.user_account_updated'));
     } else {
         $error = $user->errors()->all(':message');
         return Redirect::to('user')->withInput(Input::except('password', 'password_confirmation'))->with('error', $error);
     }
 }
开发者ID:ntk148v,项目名称:mini_cms,代码行数:28,代码来源:UserController.php


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