/**
  * Handle incoming requests.
  *
  * @param Request $request
  * @param \Closure $next
  *
  * @return \Symfony\Component\HttpFoundation\Response
  * @throws \Symfony\Component\HttpKernel\Exception\HttpException
  * @throws \InvalidArgumentException
  */
 public function handle($request, Closure $next)
 {
     if ($this->maintenance->isDownMode() && !$this->maintenance->checkAllowedIp($this->getIp())) {
         if (app()['view']->exists('errors.503')) {
             return new Response(app()['view']->make('errors.503'), 503);
         }
         return app()->abort(503, 'The application is down for maintenance.');
     }
     return $next($request);
 }
 /**
  * Test allowed ips
  */
 public function testAllowedIps()
 {
     $service = new MaintenanceModeService($this->app);
     $this->assertTrue($service->checkAllowedIp('127.0.0.1'));
     $this->assertTrue($service->checkAllowedIp('127.0.0.2'));
 }