Merge pull request 'Added validation in pdf controller checking missing' (#1499) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #1499
This commit was merged in pull request #1499.
This commit is contained in:
@@ -282,6 +282,34 @@ class PdfController extends Controller
|
|||||||
return response()->json($response, 404);
|
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();
|
$recordProdQuan = ProductionQuantity::where('plant_id', $plantId)->where('serial_number', $sNo)->first();
|
||||||
|
|
||||||
if($recordProdQuan){
|
if($recordProdQuan){
|
||||||
|
|||||||
Reference in New Issue
Block a user