Added validation in pdf controller checking missing
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Failing after 19s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 16s
Laravel Larastan / larastan (pull_request) Failing after 21m25s
Laravel Pint / pint (pull_request) Successful in 6m8s

This commit is contained in:
dhanabalan
2026-11-23 16:16:16 +05:30
parent 5362d3bcb1
commit d2b807ebee

View File

@@ -282,6 +282,34 @@ class PdfController extends Controller
return response()->json($response, 404);
}
// Get all expected characteristics from master table
$expectedCharacteristics = ProductCharacteristicsMaster::where('plant_id', $plantId)
->where('line_id', $lineId)
->where('item_id', $itemId)
->pluck('name')
->toArray();
// Get all characteristics received from API
$receivedCharacteristics = collect($data)
->pluck('characteristics_name')
->toArray();
// Find missing characteristics
$missingCharacteristics = array_diff(
$expectedCharacteristics,
$receivedCharacteristics
);
// Check whether any characteristics are missing
if (!empty($missingCharacteristics)) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => 'The following characteristics are missing: '
. implode(', ', $missingCharacteristics),
], 400);
}
$recordProdQuan = ProductionQuantity::where('plant_id', $plantId)->where('serial_number', $sNo)->first();
if($recordProdQuan){