GuestFilter.php 723 B

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