Просмотр исходного кода

库存对比导入报错修改

haozi 5 лет назад
Родитель
Сommit
8bb178bcdf
1 измененных файлов с 4 добавлено и 5 удалено
  1. 4 5
      app/Imports/InventoryCompareImport.php

+ 4 - 5
app/Imports/InventoryCompareImport.php

@@ -24,7 +24,6 @@ class InventoryCompareImport implements ToCollection, WithHeadingRow, WithMultip
     protected $ownerArr=[];
     public function __construct()
     {
-//            $this->owner_id=$owner_id;
             app()->singleton('InventoryCompareService',InventoryCompareService::class);
     }
 
@@ -45,9 +44,9 @@ class InventoryCompareImport implements ToCollection, WithHeadingRow, WithMultip
             if($array[0]['仓库']??false) return '仓库';
             if($array[0]['属性仓']??false) return '属性仓';
         })();
-        $sku=$array[0][$skuName];
-        $amount=$array[0][$amountName];
-        $customLocation=$array[0][$customLocationName];
+        $sku=$array[0][$skuName] ?? null;
+        $amount=$array[0][$amountName] ?? null;
+        $customLocation=$array[0][$customLocationName] ?? null;
 
         $endIS = false;
         if (!isset($sku) || !isset($amount) || !isset($customLocation)) {
@@ -57,7 +56,7 @@ class InventoryCompareImport implements ToCollection, WithHeadingRow, WithMultip
         }
         foreach ($collection as $row) {
             $customLocationArr=[
-                'custom_location'=>$row[$customLocationName],
+                'custom_location'=>$row[$customLocationName] ?? null,
             ];
             array_push($this->customLocationArrs,$customLocationArr);
         }