VerifyEmailController.php 800 B

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