From 4fc66e19bb42e616131583d956b738be63755fc1 Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 22 Feb 2024 18:28:01 +0000 Subject: [PATCH 1/3] Check for activeFile before trying to get header Signed-off-by: snipe --- app/Http/Livewire/Importer.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/Http/Livewire/Importer.php b/app/Http/Livewire/Importer.php index 07f3a9f16c..5dce836474 100644 --- a/app/Http/Livewire/Importer.php +++ b/app/Http/Livewire/Importer.php @@ -3,6 +3,7 @@ namespace App\Http\Livewire; use App\Models\CustomField; +use Illuminate\Http\JsonResponse; use Livewire\Component; use App\Models\Import; @@ -59,12 +60,21 @@ class Importer extends Component 'field_map' => 'array' ]; + /** + * This is used in resources/views/livewire/importer.blade.php, and we kinda shouldn't need to check for + * activeFile here, but there's some UI goofiness that allows this to crash out on some imports. + * + * @return JsonResponse + */ public function generate_field_map() { - \Log::debug("header row is: ".print_r($this->activeFile->header_row,true)); - \Log::debug("Field map is: ".print_r($this->field_map,true)); - $tmp = array_combine($this->activeFile->header_row, $this->field_map); - return json_encode(array_filter($tmp)); + $tmp = array(); + if ($this->activeFile) { + $tmp = array_combine($this->activeFile->header_row, $this->field_map); + $tmp =array_filter($tmp); + } + return json_encode($tmp); + } From dc902e7a5a1dbd573042e12d7e121bba1d3f521c Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 22 Feb 2024 18:30:23 +0000 Subject: [PATCH 2/3] Fixed return type Signed-off-by: snipe --- app/Http/Livewire/Importer.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/Http/Livewire/Importer.php b/app/Http/Livewire/Importer.php index 5dce836474..7c908f1b6d 100644 --- a/app/Http/Livewire/Importer.php +++ b/app/Http/Livewire/Importer.php @@ -3,7 +3,6 @@ namespace App\Http\Livewire; use App\Models\CustomField; -use Illuminate\Http\JsonResponse; use Livewire\Component; use App\Models\Import; @@ -64,7 +63,7 @@ class Importer extends Component * This is used in resources/views/livewire/importer.blade.php, and we kinda shouldn't need to check for * activeFile here, but there's some UI goofiness that allows this to crash out on some imports. * - * @return JsonResponse + * @return string */ public function generate_field_map() { From f04aeb9f2bcd5655b5c277021b5ce890cf442c55 Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 22 Feb 2024 18:31:02 +0000 Subject: [PATCH 3/3] Fixed spacing Signed-off-by: snipe --- app/Http/Livewire/Importer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Livewire/Importer.php b/app/Http/Livewire/Importer.php index 7c908f1b6d..0a6c52f096 100644 --- a/app/Http/Livewire/Importer.php +++ b/app/Http/Livewire/Importer.php @@ -70,7 +70,7 @@ class Importer extends Component $tmp = array(); if ($this->activeFile) { $tmp = array_combine($this->activeFile->header_row, $this->field_map); - $tmp =array_filter($tmp); + $tmp = array_filter($tmp); } return json_encode($tmp);