UnderMaintenance.php 804 B

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