當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。