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