From 166ad8cdb36a5ce80aaa8a63bc9506cc3d1b5c3c Mon Sep 17 00:00:00 2001 From: Ruben Van Assche Date: Tue, 30 Apr 2024 10:43:45 +0200 Subject: [PATCH] Handle case where an external call was made from a view --- src/Views/ViewExceptionMapper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Views/ViewExceptionMapper.php b/src/Views/ViewExceptionMapper.php index a1bb748..3872776 100644 --- a/src/Views/ViewExceptionMapper.php +++ b/src/Views/ViewExceptionMapper.php @@ -83,10 +83,10 @@ protected function modifyViewsInTrace(IgnitionViewException $exception): void { $viewIndex = null; - $trace = Collection::make($exception->getPrevious()->getTrace()) ->map(function ($trace, $index) use (&$viewIndex) { if ($originalPath = $this->findCompiledView(Arr::get($trace, 'file', ''))) { + $trace['file'] = $originalPath; $trace['line'] = $this->getBladeLineNumber($trace['file'], $trace['line']); @@ -98,7 +98,7 @@ protected function modifyViewsInTrace(IgnitionViewException $exception): void return $trace; }) ->when( - $viewIndex !== null, + $viewIndex !== null && str_ends_with($exception->getFile(), '.blade.php'), fn (Collection $trace) => $trace->slice($viewIndex + 1) // Remove all traces before the view ) ->toArray();