From 8e959e01d71b6b0766ef38ef4d537a75177c5180 Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq.com> Date: Thu, 7 May 2026 16:53:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E8=BD=A6=E7=89=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...arkingLicensePlateImportTemplateExport.php | 2 +- .../ParkingVipListImportTemplateExport.php | 4 +-- app/Imports/ParkingLicensePlateImport.php | 33 +++++++++---------- app/Imports/ParkingVipListImport.php | 4 +-- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/app/Exports/ParkingLicensePlateImportTemplateExport.php b/app/Exports/ParkingLicensePlateImportTemplateExport.php index 91a0c7a..dc2f77b 100644 --- a/app/Exports/ParkingLicensePlateImportTemplateExport.php +++ b/app/Exports/ParkingLicensePlateImportTemplateExport.php @@ -9,7 +9,7 @@ class ParkingLicensePlateImportTemplateExport implements FromArray public function array(): array { return [ - [__('exports.global.index'), __('exports.vip_list.license')], + ['No.', 'License Plate No.'], ['1', '测A88888'] ]; } diff --git a/app/Exports/ParkingVipListImportTemplateExport.php b/app/Exports/ParkingVipListImportTemplateExport.php index c473cce..6cdd477 100644 --- a/app/Exports/ParkingVipListImportTemplateExport.php +++ b/app/Exports/ParkingVipListImportTemplateExport.php @@ -10,8 +10,8 @@ class ParkingVipListImportTemplateExport implements FromArray public function array(): array { return [ - [__('exports.vip_list.license')], - ['测A88888'] + ['No.', 'License Plate No.'], + ['1', '测A88887'] ]; } } diff --git a/app/Imports/ParkingLicensePlateImport.php b/app/Imports/ParkingLicensePlateImport.php index 2fc28cb..f50c97b 100644 --- a/app/Imports/ParkingLicensePlateImport.php +++ b/app/Imports/ParkingLicensePlateImport.php @@ -28,23 +28,22 @@ class ParkingLicensePlateImport implements ToModel, WithHeadingRow */ public function model(array $row) { - $data = []; - foreach ($row as $value) { - $data[] = $value; - } - $where = [ - 'number' => $data[0], - 'space_type_id' => $this->parkingSpaceType - ]; - if (!ParkingLicensePlate::query()->where($where) - ->exists() - ) { - $model = new ParkingLicensePlate([ - 'number' => $data[0], - 'space_type_id' => $this->parkingSpaceType, - 'created_at' => get_datetime() - ]); - $this->logService->logCreated($model, 'license_plate.create'); + if (isset($row['license_plate_no']) && $row['license_plate_no']) { + $number = $row['license_plate_no']; + $where = [ + 'number' => $number, + 'space_type_id' => $this->parkingSpaceType + ]; + if (!ParkingLicensePlate::query()->where($where) + ->exists() + ) { + $model = new ParkingLicensePlate([ + 'number' => $number, + 'space_type_id' => $this->parkingSpaceType, + 'created_at' => get_datetime() + ]); + $this->logService->logCreated($model, 'license_plate.create'); + } } } } diff --git a/app/Imports/ParkingVipListImport.php b/app/Imports/ParkingVipListImport.php index 5b57672..912f48a 100644 --- a/app/Imports/ParkingVipListImport.php +++ b/app/Imports/ParkingVipListImport.php @@ -27,7 +27,8 @@ class ParkingVipListImport implements ToModel, WithHeadingRow */ public function model(array $row) { - foreach ($row as $license) { + if (isset($row['license_plate_no']) && $row['license_plate_no']) { + $license = $row['license_plate_no']; if (!ParkingVipList::query()->where('license', $license) ->exists() ) { @@ -38,7 +39,6 @@ class ParkingVipListImport implements ToModel, WithHeadingRow ]); $this->logService->logCreated($model, 'vip_list.create'); } - break; } } }