Added catch for rework scenario in panel box validation #964
@@ -180,6 +180,7 @@ public $records = [];
|
|||||||
$latestReworkRecord = PanelBoxValidation::where('plant_id', $this->data['plant_id'] ?? null)->where('serial_number', $this->data['serial_number'] ?? null)->latest()->first();
|
$latestReworkRecord = PanelBoxValidation::where('plant_id', $this->data['plant_id'] ?? null)->where('serial_number', $this->data['serial_number'] ?? null)->latest()->first();
|
||||||
|
|
||||||
if($latestReworkRecord){
|
if($latestReworkRecord){
|
||||||
|
try{
|
||||||
$qualityValidation = PanelBoxValidation::create([
|
$qualityValidation = PanelBoxValidation::create([
|
||||||
'plant_id' => $this->data['plant_id'] ?? null,
|
'plant_id' => $this->data['plant_id'] ?? null,
|
||||||
'line_id' => $this->data['line_id'] ?? null,
|
'line_id' => $this->data['line_id'] ?? null,
|
||||||
@@ -205,6 +206,15 @@ public $records = [];
|
|||||||
'updated_by' => $this->data['updated_by'] ?? null,
|
'updated_by' => $this->data['updated_by'] ?? null,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
catch (\Illuminate\Database\QueryException $e) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Duplicate Record')
|
||||||
|
->body("Duplicate serial number found against doc number '{$this->data['production_order'] }' and inspection lot number '{$this->data['inspection_lot_number']}'.")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
$qualityValidation = PanelBoxValidation::create([
|
$qualityValidation = PanelBoxValidation::create([
|
||||||
'plant_id' => $this->data['plant_id'] ?? null,
|
'plant_id' => $this->data['plant_id'] ?? null,
|
||||||
@@ -262,7 +272,6 @@ public $records = [];
|
|||||||
->body('Something went wrong while inserting data.')
|
->body('Something went wrong while inserting data.')
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user