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


PHP UserRequest::only方法代码示例

本文整理汇总了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')]);
 }
开发者ID:Marco3d,项目名称:alpha,代码行数:7,代码来源:AuthController.php

示例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');
 }
开发者ID:alons182,项目名称:guanacastevende,代码行数:13,代码来源:UsersController.php

示例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;
 }
开发者ID:laravelmtl,项目名称:api,代码行数:14,代码来源:UserController.php

示例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');
 }
开发者ID:litemax,项目名称:LaravelBlog,代码行数:8,代码来源:UserController.php

示例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');
 }
开发者ID:realnerdo,项目名称:blog,代码行数:16,代码来源:UsersController.php

示例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');
     }
 }
开发者ID:thuatnt2,项目名称:QLNV-l5,代码行数:10,代码来源:AuthController.php

示例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');
 }
开发者ID:gertjanroke,项目名称:users,代码行数:21,代码来源:UsersController.php

示例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');
 }
开发者ID:intothesource,项目名称:users,代码行数:21,代码来源:UsersController.php

示例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());
 }
开发者ID:salvo1404,项目名称:jwt-authentication,代码行数:26,代码来源:UserController.php

示例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'));
 }
开发者ID:kmassada,项目名称:laravel-angular,代码行数:27,代码来源:UserAuthController.php

示例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]);
 }
开发者ID:Kehet,项目名称:k-forum,代码行数:39,代码来源:AdminUsersController.php


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