RedirectIfAuthenticated.php 582 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App\Http\Middleware;
  3. use App\Providers\RouteServiceProvider;
  4. use Closure;
  5. use Illuminate\Support\Facades\Auth;
  6. class RedirectIfAuthenticated
  7. {
  8. /**
  9. * Handle an incoming request.
  10. *
  11. * @param \Illuminate\Http\Request $request
  12. * @param \Closure $next
  13. * @param string|null $guard
  14. * @return mixed
  15. */
  16. public function handle($request, Closure $next, $guard = null)
  17. {
  18. if (Auth::guard($guard)->check()) {
  19. return redirect(RouteServiceProvider::HOME);
  20. }
  21. return $next($request);
  22. }
  23. }