Added catch for rework scenario in panel box validation
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 14s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 20s
Laravel Pint / pint (pull_request) Successful in 8m3s
Laravel Larastan / larastan (pull_request) Failing after 10m1s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 14s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 20s
Laravel Pint / pint (pull_request) Successful in 8m3s
Laravel Larastan / larastan (pull_request) Failing after 10m1s
This commit is contained in:
@@ -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();
|
||||
|
||||
if($latestReworkRecord){
|
||||
try{
|
||||
$qualityValidation = PanelBoxValidation::create([
|
||||
'plant_id' => $this->data['plant_id'] ?? null,
|
||||
'line_id' => $this->data['line_id'] ?? null,
|
||||
@@ -205,6 +206,15 @@ public $records = [];
|
||||
'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{
|
||||
$qualityValidation = PanelBoxValidation::create([
|
||||
'plant_id' => $this->data['plant_id'] ?? null,
|
||||
@@ -262,7 +272,6 @@ public $records = [];
|
||||
->body('Something went wrong while inserting data.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user