Updated label and validation logics
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
This commit is contained in:
@@ -21,36 +21,36 @@ class MachineImporter extends Importer
|
||||
return [
|
||||
ImportColumn::make('name')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Machine Name')
|
||||
->exampleHeader('DESCRIPTION')
|
||||
->example(['1600251'])
|
||||
->label('Machine Name')
|
||||
->label('DESCRIPTION')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('work_center')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Work Center')
|
||||
->exampleHeader('WORK CENTER')
|
||||
->example('RMGCE001')
|
||||
->label('Work Center')
|
||||
->label('WORK CENTER')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('workGroupMaster')
|
||||
->requiredMapping()
|
||||
->relationship(resolveUsing: 'name')
|
||||
->exampleHeader('Work Group Center')
|
||||
->exampleHeader('GROUP WORK CENTER')
|
||||
->example(['RMGCGABC'])
|
||||
->label('Work Group Center')
|
||||
->label('GROUP WORK CENTER')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->relationship(resolveUsing: 'name')
|
||||
->exampleHeader('Line Name')
|
||||
->exampleHeader('LINE NAME')
|
||||
->example(['4 inch pump line'])
|
||||
->label('Line Name')
|
||||
->label('LINE NAME')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('plant')
|
||||
->requiredMapping()
|
||||
->relationship(resolveUsing: 'code')
|
||||
->exampleHeader('Plant Code')
|
||||
->exampleHeader('PLANT CODE')
|
||||
->example(['1000'])
|
||||
->label('Plant Code')
|
||||
->label('PLANT CODE')
|
||||
->rules(['required']),
|
||||
];
|
||||
}
|
||||
@@ -61,18 +61,27 @@ class MachineImporter extends Importer
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$line = null;
|
||||
$lineNam = $this->data['line'];
|
||||
$machine = $this->data['name'];
|
||||
$workCenter = $this->data['work_center'];
|
||||
$groupWorkCenter = WorkGroupMaster::where('name', $this->data['workGroupMaster'])->first();
|
||||
$workGroupCenter = $this->data['workGroupMaster'];
|
||||
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = 'Invalid plant code found';
|
||||
} elseif (Str::length($lineNam) <= 0) {
|
||||
$warnMsg[] = "Line name can't be empty!";
|
||||
} elseif (Str::length($machine) <= 0) {
|
||||
$warnMsg[] = "Description can't be empty!";
|
||||
} elseif (Str::length($workCenter) <= 0) {
|
||||
$warnMsg[] = "Work center can't be empty!";
|
||||
} elseif (Str::length($workGroupCenter) <= 0) {
|
||||
$warnMsg[] = "Group work center can't be empty!";
|
||||
} else {
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found!';
|
||||
} else {
|
||||
$groupWorkCenter = WorkGroupMaster::where('name', $this->data['workGroupMaster'])->where('plant_id', $plant->id)->first();
|
||||
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
||||
$groupWorkCenter = WorkGroupMaster::where('name', $workGroupCenter)->where('plant_id', $plant->id)->first();
|
||||
$line = Line::where('name', $lineNam)->where('plant_id', $plant->id)->first();
|
||||
if ($line) {
|
||||
$grpWrkCnr = $line->no_of_operation;
|
||||
if (! $grpWrkCnr || $grpWrkCnr < 1) {// Str::length($grpWrkCnr) < 1)
|
||||
@@ -106,10 +115,6 @@ class MachineImporter extends Importer
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($machine) <= 0) {
|
||||
$warnMsg[] = 'Machine name not found!';
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user