Updated plant validation logic and added bundle_quantity in get_master api #557

Merged
jothi merged 1 commits from ranjith-dev into master 2026-04-30 09:47:35 +00:00

View File

@@ -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);