当前位置: 首页>>代码示例>>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;未经允许,请勿转载。