Browse Source

导出标题翻译

master
wanghongjun 17 hours ago
parent
commit
434f8a781a
  1. 2
      app/Exports/ParkingVipListImportTemplateExport.php
  2. 12
      app/Imports/ParkingVipListImport.php

2
app/Exports/ParkingVipListImportTemplateExport.php

@ -10,7 +10,7 @@ class ParkingVipListImportTemplateExport implements FromArray
public function array(): array public function array(): array
{ {
return [ return [
['No.', 'License Plate No.'], [__exports('global.index'), __exports('parking_space.license_plate')],
['1', '测A88887'] ['1', '测A88887']
]; ];
} }

12
app/Imports/ParkingVipListImport.php

@ -7,15 +7,15 @@ use App\Services\OperationLogService;
use App\Services\ParkingLicensePlateService; use App\Services\ParkingLicensePlateService;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Maatwebsite\Excel\Concerns\ToModel; use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
class ParkingVipListImport implements ToModel, WithHeadingRow class ParkingVipListImport implements ToModel
{ {
/** /**
* @var OperationLogService * @var OperationLogService
*/ */
private OperationLogService $logService; private OperationLogService $logService;
protected int $index = 1;
public function __construct() public function __construct()
{ {
@ -28,8 +28,12 @@ class ParkingVipListImport implements ToModel, WithHeadingRow
*/ */
public function model(array $row) public function model(array $row)
{ {
if (isset($row['license_plate_no']) && $row['license_plate_no']) { if ($this->index == 1) {
$license = $row['license_plate_no']; $this->index += 1;
return;
}
if (isset($row[1]) && $row[1]) {
$license = $row[1];
$license_id = (new ParkingLicensePlateService($this->logService))->createLicenseId($license); $license_id = (new ParkingLicensePlateService($this->logService))->createLicenseId($license);
if (!ParkingVipList::query()->where('license_id', $license_id) if (!ParkingVipList::query()->where('license_id', $license_id)
->exists() ->exists()

Loading…
Cancel
Save