GuestFilter.php 585 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php namespace App\Http\Filters;
  2. use Illuminate\Contracts\Auth\Authenticator;
  3. use Illuminate\Http\RedirectResponse;
  4. class GuestFilter {
  5. /**
  6. * The authenticator implementation.
  7. *
  8. * @var Authenticator
  9. */
  10. protected $auth;
  11. /**
  12. * Create a new filter instance.
  13. *
  14. * @param Authenticator $auth
  15. * @return void
  16. */
  17. public function __construct(Authenticator $auth)
  18. {
  19. $this->auth = $auth;
  20. }
  21. /**
  22. * Run the request filter.
  23. *
  24. * @return mixed
  25. */
  26. public function filter()
  27. {
  28. if ($this->auth->check())
  29. {
  30. return new RedirectResponse(url('/'));
  31. }
  32. }
  33. }