diff --git a/app/Exports/ParkingVipListImportTemplateExport.php b/app/Exports/ParkingVipListImportTemplateExport.php index 6cdd477..8b7ed74 100644 --- a/app/Exports/ParkingVipListImportTemplateExport.php +++ b/app/Exports/ParkingVipListImportTemplateExport.php @@ -10,7 +10,7 @@ class ParkingVipListImportTemplateExport implements FromArray public function array(): array { return [ - ['No.', 'License Plate No.'], + [__exports('global.index'), __exports('parking_space.license_plate')], ['1', '测A88887'] ]; } diff --git a/app/Imports/ParkingVipListImport.php b/app/Imports/ParkingVipListImport.php index a9a0712..3c70e30 100644 --- a/app/Imports/ParkingVipListImport.php +++ b/app/Imports/ParkingVipListImport.php @@ -7,15 +7,15 @@ use App\Services\OperationLogService; use App\Services\ParkingLicensePlateService; use Illuminate\Support\Facades\Auth; use Maatwebsite\Excel\Concerns\ToModel; -use Maatwebsite\Excel\Concerns\WithHeadingRow; -class ParkingVipListImport implements ToModel, WithHeadingRow +class ParkingVipListImport implements ToModel { /** * @var OperationLogService */ private OperationLogService $logService; + protected int $index = 1; public function __construct() { @@ -28,8 +28,12 @@ class ParkingVipListImport implements ToModel, WithHeadingRow */ public function model(array $row) { - if (isset($row['license_plate_no']) && $row['license_plate_no']) { - $license = $row['license_plate_no']; + if ($this->index == 1) { + $this->index += 1; + return; + } + if (isset($row[1]) && $row[1]) { + $license = $row[1]; $license_id = (new ParkingLicensePlateService($this->logService))->createLicenseId($license); if (!ParkingVipList::query()->where('license_id', $license_id) ->exists()