No Description

RedirectIfAuthenticated.php 706B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php namespace App\Http\Middleware;
  2. use Closure;
  3. use Illuminate\Contracts\Auth\Guard;
  4. use Illuminate\Http\RedirectResponse;
  5. class RedirectIfAuthenticated {
  6. /**
  7. * The Guard implementation.
  8. *
  9. * @var Guard
  10. */
  11. protected $auth;
  12. /**
  13. * Create a new filter instance.
  14. *
  15. * @param Guard $auth
  16. * @return void
  17. */
  18. public function __construct(Guard $auth)
  19. {
  20. $this->auth = $auth;
  21. }
  22. /**
  23. * Handle an incoming request.
  24. *
  25. * @param \Illuminate\Http\Request $request
  26. * @param \Closure $next
  27. * @return mixed
  28. */
  29. public function handle($request, Closure $next)
  30. {
  31. if ($this->auth->check())
  32. {
  33. return new RedirectResponse(url('/home'));
  34. }
  35. return $next($request);
  36. }
  37. }