From d2b807ebeee1073021ac783ae8d08c5372ff3716 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 23 Nov 2026 16:16:16 +0530 Subject: [PATCH] Added validation in pdf controller checking missing --- app/Http/Controllers/PdfController.php | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/app/Http/Controllers/PdfController.php b/app/Http/Controllers/PdfController.php index e4c72cf7..bda564f9 100644 --- a/app/Http/Controllers/PdfController.php +++ b/app/Http/Controllers/PdfController.php @@ -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){