GuestFilter.php 540 B

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