app = $app; } public function temporarilyDisableExceptionHandlingAndMiddleware($callback) { $cachedHandler = app(ExceptionHandler::class); $cachedShouldSkipMiddleware = $this->app->shouldSkipMiddleware(); $this->withoutExceptionHandling([HttpException::class, AuthorizationException::class])->withoutMiddleware(); $callback($this); $this->app->instance(ExceptionHandler::class, $cachedHandler); if (! $cachedShouldSkipMiddleware) { unset($this->app['middleware.disable']); } } public function withoutHandling($except = []) { return $this->withoutExceptionHandling($except); } }