EmailVerificationNotificationController.php 662 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace App\Http\Controllers\Auth;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Http\JsonResponse;
  5. use Illuminate\Http\RedirectResponse;
  6. use Illuminate\Http\Request;
  7. class EmailVerificationNotificationController extends Controller
  8. {
  9. /**
  10. * Send a new email verification notification.
  11. */
  12. public function store(Request $request): JsonResponse|RedirectResponse
  13. {
  14. if ($request->user()->hasVerifiedEmail()) {
  15. return redirect()->intended('/dashboard');
  16. }
  17. $request->user()->sendEmailVerificationNotification();
  18. return response()->json(['status' => 'verification-link-sent']);
  19. }
  20. }