當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::newInstance方法代碼示例

本文整理匯總了PHP中app\models\User::newInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::newInstance方法的具體用法?PHP User::newInstance怎麽用?PHP User::newInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\User的用法示例。


在下文中一共展示了User::newInstance方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: finish

 /**
  * Finishes the administration setup.
  *
  * @param SetupRequest $request
  *
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
  */
 public function finish(SetupRequest $request)
 {
     $user = $this->user->newInstance();
     if ($this->dispatch(new Finish($request, $user))) {
         return view('admin.setup.complete');
     }
     flash()->error('Error!', 'There was an issue completing setup. Please try again.');
     return redirect()->route('admin.setup.begin');
 }
開發者ID:stevebauman,項目名稱:ithub,代碼行數:16,代碼來源:SetupController.php

示例2: store

 /**
  * Creates a new user.
  *
  * @param UserRequest $request
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(UserRequest $request)
 {
     $this->authorize('admin.users.create');
     $user = $this->user->newInstance();
     if ($this->dispatch(new Store($request, $user))) {
         flash()->success('Success!', 'Successfully created user.');
         return redirect()->route('admin.users.index');
     }
     flash()->error('Error!', 'There was an issue creating a user. Please try again.');
     return redirect()->route('admin.users.create');
 }
開發者ID:stevebauman,項目名稱:ithub,代碼行數:18,代碼來源:UserController.php

示例3: handle

 /**
  * Creates a new user.
  *
  * @param User $model
  *
  * @return User|bool
  */
 public function handle(User $model)
 {
     $exists = $model->where('email', $this->email)->first();
     if (is_null($exists)) {
         $user = $model->newInstance();
         $user->email = $this->email;
         $user->name = $this->name;
         if ($user->hasSetMutator('password')) {
             // If the user model has a password set mutator, we'll assume
             // the developer is encrypting the passwords themselves.
             $user->password = $this->password;
         } else {
             // Otherwise we'll encrypt the password.
             $user->password = bcrypt($this->password);
         }
         $user->save();
         return $user;
     }
     return false;
 }
開發者ID:stevebauman,項目名稱:ithub,代碼行數:27,代碼來源:Create.php

示例4: finish

 /**
  * Finishes the administration setup.
  *
  * @param SetupRequest $request
  *
  * @return bool
  */
 public function finish(SetupRequest $request)
 {
     $user = $this->user->newInstance();
     return $this->dispatch(new Finish($request, $user));
 }
開發者ID:stevebauman,項目名稱:administration,代碼行數:12,代碼來源:SetupProcessor.php

示例5: store

 /**
  * Creates a new user.
  *
  * @param UserRequest $request
  *
  * @return bool
  */
 public function store(UserRequest $request)
 {
     $this->authorize('admin.users.create');
     $user = $this->user->newInstance();
     return $this->dispatch(new Store($request, $user));
 }
開發者ID:stevebauman,項目名稱:administration,代碼行數:13,代碼來源:UserProcessor.php

示例6: newInstance

 public function newInstance($attributes = [])
 {
     return $this->user->newInstance($attributes = []);
 }
開發者ID:rtablada,項目名稱:student-grading,代碼行數:4,代碼來源:DbUserGateway.php

示例7: handleProviderCallback

 /**
  * Obtain the user information from Provider.
  *
  * @param  string          $provider
  * @param  Socialite|SocialiteManager       $socialite
  * @param  User  $userModel
  *
  * @throws UnprocessableEntityException
  *
  * @return ApiResponse
  */
 public function handleProviderCallback($provider, Socialite $socialite, User $userModel)
 {
     $this->validateProvider($provider);
     $socialUser = $socialite->with($provider)->user();
     // Verify so we received an email address, if using oAuth credentials
     // with Twitter for instance, that isn't whitelisted, no email
     // address will be returned with the response.
     // See the notes in Spira API doc under Social Login for more info.
     if (!$socialUser->email) {
         // The app is connected with the service, but the 3rd party service
         // is not configured or allowed to return email addresses, so we
         // can't process the data further. Let's throw an exception.
         \Log::critical('Provider ' . $provider . ' does not return email.');
         throw new UnprocessableEntityException('User object has no email');
     }
     // Parse the social user to fit within Spira's user model
     $socialUser = ParserFactory::parse($socialUser, $provider);
     // Get or create the Spira user from the social login
     try {
         $user = $userModel->findByEmail($socialUser->email);
     } catch (ModelNotFoundException $e) {
         $user = $userModel->newInstance();
         $user->fill(array_merge($socialUser->toArray(), ['user_type' => 'guest']));
         $user->save();
     }
     $socialLogin = new SocialLogin(['provider' => $provider, 'token' => $socialUser->token]);
     $user->addSocialLogin($socialLogin);
     // Prepare response data
     $token = $this->jwtAuth->fromUser($user, ['method' => $provider]);
     $returnUrl = $socialite->with($provider)->getCachedReturnUrl() . '?jwtAuthToken=' . $token;
     $response = $this->getResponse();
     $response->redirect($returnUrl, 302);
     return $response;
 }
開發者ID:TFidryForks,項目名稱:spira,代碼行數:45,代碼來源:AuthController.php


注:本文中的app\models\User::newInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。