MaintenanceFilter.php 800 B

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