Last active
August 11, 2021 23:43
-
-
Save patrickcurl/9ad28b8b3e5d81be1f221be8693e436d to your computer and use it in GitHub Desktop.
Laravel Breeze Tutorial PasswordResetLinkController@store
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function store(Request $request) | |
{ | |
$loginField = filter_var( | |
$request->input('login'), FILTER_VALIDATE_EMAIL) | |
? 'email' | |
: 'username'; | |
$request->merge([$loginField => $request->input('login')]); | |
$request->validate([ | |
'email' => 'required_without:username|email|exists:users,email', | |
'username' => | |
'required_without:email|string|exists:users,username' | |
]); | |
$status = Password::sendResetLink( | |
$request->only($loginField) | |
); | |
if ($status == Password::RESET_LINK_SENT) { | |
return back()->with('status', __($status)); | |
} | |
throw ValidationException::withMessages([ | |
$loginField => [trans($status)], | |
]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment