Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] Simplifying UpdateUserProfileInformation.php #575

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 10 additions & 21 deletions stubs/UpdateUserProfileInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,19 @@ public function update(User $user, array $input): void
],
])->validateWithBag('updateProfileInformation');

if ($input['email'] !== $user->email &&
$user instanceof MustVerifyEmail) {
$this->updateVerifiedUser($user, $input);
} else {
$user->forceFill([
'name' => $input['name'],
'email' => $input['email'],
])->save();
}
}

/**
* Update the given verified user's profile information.
*
* @param array<string, string> $input
*/
protected function updateVerifiedUser(User $user, array $input): void
{
$user->forceFill([
'name' => $input['name'],
'email' => $input['email'],
'email_verified_at' => null,
])->save();
]);

if ($user->isDirty('email') && $user instanceof MustVerifyEmail) {
$user->email_verified_at = null;
}

$user->save();

$user->sendEmailVerificationNotification();
if ($user->wasChanged('email') && $user instanceof MustVerifyEmail) {
$user->sendEmailVerificationNotification();
}
}
}