本文整理汇总了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);
}
}
}
示例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']);
}
示例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);
}
}
示例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);
}
}