diff --git a/src/Illuminate/Foundation/helpers.php b/src/Illuminate/Foundation/helpers.php index 3327a98e306e..8f9fff77b999 100644 --- a/src/Illuminate/Foundation/helpers.php +++ b/src/Illuminate/Foundation/helpers.php @@ -6,12 +6,15 @@ use Illuminate\Container\Container; use Illuminate\Contracts\Bus\Dispatcher; use Illuminate\Contracts\Auth\Access\Gate; +use Illuminate\Contracts\Support\Responsable; use Illuminate\Contracts\Routing\UrlGenerator; use Illuminate\Foundation\Bus\PendingDispatch; +use Symfony\Component\HttpFoundation\Response; use Illuminate\Contracts\Debug\ExceptionHandler; use Illuminate\Contracts\Routing\ResponseFactory; use Illuminate\Contracts\Auth\Factory as AuthFactory; use Illuminate\Contracts\View\Factory as ViewFactory; +use Illuminate\Http\Exceptions\HttpResponseException; use Illuminate\Contracts\Cookie\Factory as CookieFactory; use Symfony\Component\Debug\Exception\FatalThrowableError; use Illuminate\Database\Eloquent\Factory as EloquentFactory; @@ -22,7 +25,7 @@ /** * Throw an HttpException with the given data. * - * @param int $code + * @param \Symfony\Component\HttpFoundation\Response|int $code * @param string $message * @param array $headers * @return void @@ -32,6 +35,12 @@ */ function abort($code, $message = '', array $headers = []) { + if ($code instanceof Response) { + throw new HttpResponseException($code); + } elseif ($code instanceof Responsable) { + throw new HttpResponseException($code->toResponse(request())); + } + app()->abort($code, $message, $headers); } }