Added validation in pdf controller checking missing #1499
@@ -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){
|
||||
|
||||
Reference in New Issue
Block a user