From c568c2c8f7515910991a93c83de021b4595bc162 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Thu, 30 Apr 2026 15:10:44 +0530 Subject: [PATCH] Updated plant validation logic and added bundle_quantity in get_master api --- .../Controllers/StickerMasterController.php | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/StickerMasterController.php b/app/Http/Controllers/StickerMasterController.php index 16292bc..f7fd322 100644 --- a/app/Http/Controllers/StickerMasterController.php +++ b/app/Http/Controllers/StickerMasterController.php @@ -48,7 +48,17 @@ class StickerMasterController extends Controller 'status_code' => 'ERROR', 'status_description' => "Plant code can't be empty!", ], 400); - } elseif (Str::length($plantCode) < 4 || ! is_numeric($plantCode) || ! preg_match('/^[1-9]\d{3,}$/', $plantCode)) { + } elseif (! is_numeric($plantCode)) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => 'Plant code should contain only numeric values!', + ], 400); + } elseif (Str::length($plantCode) < 4 || Str::length($plantCode) > 7) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => 'Plant code must be between 4 and 7 digits only!', + ], 400); + } elseif (! preg_match('/^[1-9]\d{6,}$/', $plantCode)) { return response()->json([ 'status_code' => 'ERROR', 'status_description' => 'Invalid plant code found!', @@ -170,7 +180,17 @@ class StickerMasterController extends Controller 'status_code' => 'ERROR', 'status_description' => "Plant code can't be empty!", ], 400); - } elseif (Str::length($plantCode) < 4 || ! is_numeric($plantCode) || ! preg_match('/^[1-9]\d{3,}$/', $plantCode)) { + } elseif (! is_numeric($plantCode)) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => 'Plant code should contain only numeric values!', + ], 400); + } elseif (Str::length($plantCode) < 4 || Str::length($plantCode) > 7) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => 'Plant code must be between 4 and 7 digits only!', + ], 400); + } elseif (! preg_match('/^[1-9]\d{6,}$/', $plantCode)) { return response()->json([ 'status_code' => 'ERROR', 'status_description' => 'Invalid plant code found!', @@ -192,7 +212,7 @@ class StickerMasterController extends Controller if (! $plant) { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => 'Plant not found!', + 'status_description' => 'Plant Code not found!', ], 400); } @@ -212,7 +232,7 @@ class StickerMasterController extends Controller if (! $item) { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => "Item Code not found in item table for the plant : '$plant->name'!", + 'status_description' => "Item Code not found for the plant : '$plant->name' in item table!", ], 404); } @@ -238,7 +258,7 @@ class StickerMasterController extends Controller if (! $stickerMaster) { return response()->json([ 'status_code' => 'ERROR', - 'status_description' => "Item Code not found in sticker master table for the plant : '$plant->name'!", + 'status_description' => "Item Code not found for the plant : '$plant->name' in sticker master table!", ], 404); } @@ -250,6 +270,7 @@ class StickerMasterController extends Controller 'Part_Validation_3' => $stickerMaster?->laser_part_validation3 ?? '', 'Part_Validation_4' => $stickerMaster?->laser_part_validation4 ?? '', 'Part_Validation_5' => $stickerMaster?->laser_part_validation5 ?? '', + 'bundle_quantity' => (string) $stickerMaster?->bundle_quantity ?? '0', ]; return response()->json($output, 200); -- 2.49.1