mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 22:19:41 -08:00
Check for empty headers in import
This commit is contained in:
parent
858d382e26
commit
0fd940ffa4
|
@ -43,6 +43,20 @@ class ItemImportRequest extends FormRequest
|
||||||
$import->save();
|
$import->save();
|
||||||
$fieldMappings=[];
|
$fieldMappings=[];
|
||||||
if ($import->field_map) {
|
if ($import->field_map) {
|
||||||
|
|
||||||
|
// This checks to make sure the field header has been mapped.
|
||||||
|
// If it hasn't been, it will throw an array_flip error
|
||||||
|
foreach ($import->field_map as $field => $fieldValue) {
|
||||||
|
$errorMessage = null;
|
||||||
|
|
||||||
|
if(is_null($fieldValue)){
|
||||||
|
$errorMessage = 'All import fields must be mapped.';
|
||||||
|
$this->errorCallback($import, $field, $errorMessage);
|
||||||
|
|
||||||
|
return $this->errors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// We submit as csv field: column, but the importer is happier if we flip it here.
|
// We submit as csv field: column, but the importer is happier if we flip it here.
|
||||||
$fieldMappings = array_change_key_case(array_flip($import->field_map), CASE_LOWER);
|
$fieldMappings = array_change_key_case(array_flip($import->field_map), CASE_LOWER);
|
||||||
// dd($fieldMappings);
|
// dd($fieldMappings);
|
||||||
|
|
Loading…
Reference in a new issue