本文整理汇总了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');
}
示例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');
}
示例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;
}
示例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));
}
示例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));
}
示例6: newInstance
public function newInstance($attributes = [])
{
return $this->user->newInstance($attributes = []);
}
示例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;
}