1 parent 858d382 commit 0fd940fCopy full SHA for 0fd940f
1 file changed
app/Http/Requests/ItemImportRequest.php
@@ -43,6 +43,20 @@ public function import(Import $import)
43
$import->save();
44
$fieldMappings=[];
45
if ($import->field_map) {
46
+
47
+ // This checks to make sure the field header has been mapped.
48
+ // If it hasn't been, it will throw an array_flip error
49
+ foreach ($import->field_map as $field => $fieldValue) {
50
+ $errorMessage = null;
51
52
+ if(is_null($fieldValue)){
53
+ $errorMessage = 'All import fields must be mapped.';
54
+ $this->errorCallback($import, $field, $errorMessage);
55
56
+ return $this->errors;
57
+ }
58
59
60
// We submit as csv field: column, but the importer is happier if we flip it here.
61
$fieldMappings = array_change_key_case(array_flip($import->field_map), CASE_LOWER);
62
// dd($fieldMappings);
0 commit comments