本文整理汇总了PHP中App\Http\Requests\UserRequest::only方法的典型用法代码示例。如果您正苦于以下问题:PHP UserRequest::only方法的具体用法?PHP UserRequest::only怎么用?PHP UserRequest::only使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Http\Requests\UserRequest
的用法示例。
在下文中一共展示了UserRequest::only方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postLogin
protected function postLogin(UserRequest $request)
{
if (Auth::attempt($request->only('email', 'password'), $request->has('remember_me'))) {
return Redirect::intended();
}
return Redirect::route('login')->withInput($request->only('email', 'remember_me'))->withErrors(['email' => Lang::get('auth.email_error_login')]);
}
示例2: store
/**
* Store a newly created user in storage.
*
* @param UserRequest $request
* @return Response
*/
public function store(UserRequest $request)
{
$input = $request->only('username', 'email', 'password', 'password_confirmation');
$this->userRepository->store($input);
Flash::message('User created');
return Redirect()->route('users');
}
示例3: update
/**
* Update the specified resource in storage.
*
* @param UserRequest $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(UserRequest $request, $id)
{
$user = \App\User::findOrFail($id);
$user->fill($request->only('name', 'email'));
$user->save();
return $user;
}
示例4: update
public function update(User $user, UserRequest $request)
{
$this->authorize('update', $user);
$data = $request->only(['nickname', 'website', 'weibo', 'qq', 'github', 'description']);
$user->update($data);
flash()->message('修改成功!');
return redirect('user/' . $user->id . '/edit');
}
示例5: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param User $user
* @return \Illuminate\Http\Response
*/
public function update(UserRequest $request, User $user)
{
$user->update($request->only(['name', 'occupation', 'bio', 'email']));
$files_id[] = $request->hasFile('photo') ? $this->uploadFile($user, $request->file('photo'), 'profile_photo') : $request->input('photo_id');
$files_id[] = $request->hasFile('cover') ? $this->uploadFile($user, $request->file('cover'), 'profile_cover') : $request->input('cover_id');
$user->files()->sync($files_id);
session()->flash('flash_message', 'Se han actualizado los datos de perfil');
return redirect('admin/settings?tab=profile');
}
示例6: update
public function update(UserRequest $request, $id)
{
// ajax
try {
$this->user->update($id, $request->only('username', 'fullname', 'role'));
return redirect()->action('Auth\\AuthController@getRegister');
} catch (Exception $e) {
return redirect()->back()->withInput()->with('error', 'Không thể truy vấn dữ liệu');
}
}
示例7: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @param UserRequest $request
* @return Response
*/
public function update(UserRequest $request, $id)
{
$user = User::findOrFail($id);
if ($request->get('password') && Auth::attempt(['email' => $user->email, 'password' => $request->old_password])) {
$request['password'] = bcrypt($request->get('password'));
} elseif (!$request->get('password')) {
$request['password'] = $user->password;
} else {
return redirect()->back()->withInput()->withErrors(['old_password' => 'Het opgegeven huidig wachtwoord is niet correct.']);
}
$user->update($request->only($user->getFillable()));
$user->roles()->sync(collect($request->get('role'))->all());
return redirect()->route('user.manager.index');
}
示例8: update
/**
* Update the specified resource in storage.
*
* @param UserRequest $request
* @param int $id
* @return Response
*/
public function update(UserRequest $request, $id)
{
$user = User::findOrFail($id);
if ($request->get('password') && bcrypt($request->get('old_password')) == $user->password) {
$request['password'] = bcrypt($request->get('password'));
} elseif (!$request->get('password')) {
$request['password'] = $user->password;
} else {
return redirect()->back()->withInput()->withErrors(['password' => 'The given password is not correct.']);
}
$user->update($request->only($user->getFillable()));
$user->roles()->sync(collect($request->get('role'))->all());
return redirect()->route('user.manager.index');
}
示例9: store
/**
* @Post("api/users", as="api.users")
*
* @Middleware("guest")
*
* @param UserRequest $request
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function store(UserRequest $request)
{
$data = $request->all();
$user = $this->userRepository->store($data);
$code = $this->activationRepository->store($user->email);
Event::fire(new Activation($user, $code));
$credentials = $request->only('email', 'password');
try {
if (!($token = JWTAuth::attempt($credentials))) {
return $this->respondWithError('Invalid Credentials');
}
} catch (JWTException $e) {
return $this->respondTokenCreationFailed('Could Not Create Token');
}
$user = JWTAuth::toUser($token);
return $this->fractal->item(['token' => $token, 'user' => $user], new AuthenticationTransformer());
}
示例10: register
/**
* Register User.
*
* @param UserRequest $request HTTP
*
* @return JSon_Codes 400/401/500
*/
public function register(UserRequest $request)
{
Log::info("[App\\UserAuthController]: Register new user");
// Get user credentials
$credentials = $request->only('name', 'email', 'password');
$credentials['password'] = bcrypt($credentials['password']);
try {
// Try to create user based on credentials provided
$user = User::create($credentials);
} catch (Exception $e) {
return response()->json(['error' => 'User already exists.'], HttpResponse::HTTP_CONFLICT);
}
// If user has social Element, create an accout for fuser
if (isset($request['provider']) && isset($request['provider_id']) && isset($request['provider_token'])) {
$user->accounts()->save(new Account(['provider' => $request['provider'], 'provider_id' => $request['provider_id'], 'access_token' => $request['provider_token']]));
}
// Return user credentials for immediate login
$token = $this->auth->fromUser($user);
return response()->json(compact('token'));
}
示例11: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @param UserRequest $request
* @return Response
*/
public function update($id, UserRequest $request)
{
$user = Sentinel::findById($id);
$credentials = $request->only(['first_name', 'last_name', 'email']);
if ($request->has('password')) {
$credentials['password'] = $request->get('password');
}
$valid = Sentinel::getUserRepository()->validForUpdate($user, $credentials);
if ($valid === false) {
echo 'error';
return false;
}
Sentinel::getUserRepository()->update($user, $credentials);
if ($request->get('active') != Activation::completed($user)) {
if ($request->get('active')) {
$activation = Activation::create($user);
Activation::complete($user, $activation->code);
} else {
Activation::remove($user);
}
}
$roles = Sentinel::getRoleRepository()->all();
$wantedRoles = $request->get('role');
foreach ($roles as $role) {
if (in_array($role->id, $wantedRoles) && !$user->inRole($role)) {
$role->users()->attach($user);
} elseif (!in_array($role->id, $wantedRoles) && $user->inRole($role)) {
$role->users()->detach($user);
}
}
return redirect()->route('admin.users.show', [$user->id]);
}