Updated alignments on import
This commit is contained in:
@@ -51,16 +51,16 @@ class PlantImporter extends Importer
|
||||
$warnMsg = [];
|
||||
$company = Company::where('name', $this->data['company'])->first();
|
||||
if (! $company) {
|
||||
$warnMsg[] = "Company name not found";
|
||||
$warnMsg[] = 'Company name not found';
|
||||
}
|
||||
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'])) {
|
||||
$warnMsg[] = "Invalid plant code found";
|
||||
$warnMsg[] = 'Invalid plant code found';
|
||||
}
|
||||
if (Str::length($this->data['address']) < 3) {
|
||||
$warnMsg[] = "Invalid address found";
|
||||
$warnMsg[] = 'Invalid address found';
|
||||
}
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
@@ -71,10 +71,9 @@ class PlantImporter extends Importer
|
||||
$plantCode = Plant::where('code', $this->data['code'])->first();
|
||||
$plantName = Plant::where('name', $this->data['name'])->first();
|
||||
if ($plantName) {
|
||||
throw new RowImportFailedException("Duplicate plant name found");
|
||||
}
|
||||
else if ($plantCode) {
|
||||
throw new RowImportFailedException("Duplicate plant code found");
|
||||
throw new RowImportFailedException('Duplicate plant name found');
|
||||
} elseif ($plantCode) {
|
||||
throw new RowImportFailedException('Duplicate plant code found');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +83,7 @@ class PlantImporter extends Importer
|
||||
],
|
||||
[
|
||||
'address' => $this->data['address'],
|
||||
'company_id' => $company->id
|
||||
'company_id' => $company->id,
|
||||
]
|
||||
);
|
||||
// return Plant::firstOrNew([
|
||||
|
||||
Reference in New Issue
Block a user