PasswordResetLinkController.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App\Http\Controllers\Auth;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Http\RedirectResponse;
  5. use Illuminate\Http\Request;
  6. use Illuminate\Support\Facades\Password;
  7. use Illuminate\Validation\ValidationException;
  8. use Illuminate\View\View;
  9. class PasswordResetLinkController extends Controller
  10. {
  11. /**
  12. * Display the password reset link request view.
  13. */
  14. public function create(): View
  15. {
  16. return view('auth.forgot-password');
  17. }
  18. /**
  19. * Handle an incoming password reset link request.
  20. *
  21. * @throws ValidationException
  22. */
  23. public function store(Request $request): RedirectResponse
  24. {
  25. $request->validate([
  26. 'email' => ['required', 'email'],
  27. ]);
  28. // We will send the password reset link to this user. Once we have attempted
  29. // to send the link, we will examine the response then see the message we
  30. // need to show to the user. Finally, we'll send out a proper response.
  31. $status = Password::sendResetLink(
  32. $request->only('email')
  33. );
  34. return $status == Password::RESET_LINK_SENT
  35. ? back()->with('status', __($status))
  36. : back()->withInput($request->only('email'))
  37. ->withErrors(['email' => __($status)]);
  38. }
  39. }