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

This commit is contained in:
dhanabalan
2026-08-29 11:13:34 +05:30
parent d2b104eaf3
commit 541793613c

View File

@@ -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;
}