VerifyEmailController.php 900 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace App\Http\Controllers\Auth;
  3. use App\Http\Controllers\Controller;
  4. use App\Providers\RouteServiceProvider;
  5. use Illuminate\Auth\Events\Verified;
  6. use Illuminate\Foundation\Auth\EmailVerificationRequest;
  7. class VerifyEmailController extends Controller
  8. {
  9. /**
  10. * Mark the authenticated user's email address as verified.
  11. *
  12. * @param \Illuminate\Foundation\Auth\EmailVerificationRequest $request
  13. * @return \Illuminate\Http\RedirectResponse
  14. */
  15. public function __invoke(EmailVerificationRequest $request)
  16. {
  17. if ($request->user()->hasVerifiedEmail()) {
  18. return redirect()->intended(RouteServiceProvider::HOME.'?verified=1');
  19. }
  20. if ($request->user()->markEmailAsVerified()) {
  21. event(new Verified($request->user()));
  22. }
  23. return redirect()->intended(RouteServiceProvider::HOME.'?verified=1');
  24. }
  25. }