Updated alignments on import
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
This commit is contained in:
@@ -51,16 +51,16 @@ class PlantImporter extends Importer
|
|||||||
$warnMsg = [];
|
$warnMsg = [];
|
||||||
$company = Company::where('name', $this->data['company'])->first();
|
$company = Company::where('name', $this->data['company'])->first();
|
||||||
if (! $company) {
|
if (! $company) {
|
||||||
$warnMsg[] = "Company name not found";
|
$warnMsg[] = 'Company name not found';
|
||||||
}
|
}
|
||||||
if (Str::length($this->data['name']) < 0) {
|
if (Str::length($this->data['name']) < 0) {
|
||||||
$warnMsg[] = "Plant name not found";
|
$warnMsg[] = 'Plant name not found';
|
||||||
}
|
}
|
||||||
if (Str::length($this->data['code']) < 4 || ! is_numeric($this->data['code']) || ! preg_match('/^[1-9]\d{3,}$/', $this->data['code'])) {
|
if (Str::length($this->data['code']) < 4 || ! is_numeric($this->data['code']) || ! preg_match('/^[1-9]\d{3,}$/', $this->data['code'])) {
|
||||||
$warnMsg[] = "Invalid plant code found";
|
$warnMsg[] = 'Invalid plant code found';
|
||||||
}
|
}
|
||||||
if (Str::length($this->data['address']) < 3) {
|
if (Str::length($this->data['address']) < 3) {
|
||||||
$warnMsg[] = "Invalid address found";
|
$warnMsg[] = 'Invalid address found';
|
||||||
}
|
}
|
||||||
if (! empty($warnMsg)) {
|
if (! empty($warnMsg)) {
|
||||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||||
@@ -71,10 +71,9 @@ class PlantImporter extends Importer
|
|||||||
$plantCode = Plant::where('code', $this->data['code'])->first();
|
$plantCode = Plant::where('code', $this->data['code'])->first();
|
||||||
$plantName = Plant::where('name', $this->data['name'])->first();
|
$plantName = Plant::where('name', $this->data['name'])->first();
|
||||||
if ($plantName) {
|
if ($plantName) {
|
||||||
throw new RowImportFailedException("Duplicate plant name found");
|
throw new RowImportFailedException('Duplicate plant name found');
|
||||||
}
|
} elseif ($plantCode) {
|
||||||
else if ($plantCode) {
|
throw new RowImportFailedException('Duplicate plant code found');
|
||||||
throw new RowImportFailedException("Duplicate plant code found");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +83,7 @@ class PlantImporter extends Importer
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
'address' => $this->data['address'],
|
'address' => $this->data['address'],
|
||||||
'company_id' => $company->id
|
'company_id' => $company->id,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// return Plant::firstOrNew([
|
// return Plant::firstOrNew([
|
||||||
|
|||||||
Reference in New Issue
Block a user