Skip to content

Instantly share code, notes, and snippets.

@patrickcurl
Last active August 11, 2021 23:43
Show Gist options
  • Save patrickcurl/9ad28b8b3e5d81be1f221be8693e436d to your computer and use it in GitHub Desktop.
Save patrickcurl/9ad28b8b3e5d81be1f221be8693e436d to your computer and use it in GitHub Desktop.
Laravel Breeze Tutorial PasswordResetLinkController@store
<?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