Updated to post api from get api and its responses
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 17s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 17s
Laravel Larastan / larastan (pull_request) Failing after 7m59s
Laravel Pint / pint (pull_request) Successful in 11m12s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 17s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 17s
Laravel Larastan / larastan (pull_request) Failing after 7m59s
Laravel Pint / pint (pull_request) Successful in 11m12s
This commit is contained in:
@@ -498,39 +498,47 @@ class TestingPanelController extends Controller
|
|||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => 'Invalid authorization token!',
|
'status_description' => 'Invalid authorization token!',
|
||||||
|
'status_response' => (object) [],
|
||||||
], 403);
|
], 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
$plantCode = $request->header('plant-code') ?? null;
|
$plantCode = trim($request->header('plant-code')) ?? null;
|
||||||
$serialNumbers = $request->header('serial-numbers') ?? null;
|
// $serialNumbers = $request->header('serial-numbers') ?? null;
|
||||||
// $description = $item ? $item->description : '';
|
$data = $request->all();
|
||||||
|
$serialNumbers = $data['serial_numbers'] ?? '';
|
||||||
|
// $serialNumbers = $request->input('serial_numbers', []);
|
||||||
|
|
||||||
if ($plantCode == null || $plantCode == '' || ! $plantCode) {
|
if ($plantCode == null || $plantCode == '' || ! $plantCode) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Plant code can't be empty!",
|
'status_description' => "Plant code can't be empty!",
|
||||||
|
'status_response' => (object) [],
|
||||||
], 404);
|
], 404);
|
||||||
} elseif (! is_numeric($plantCode)) {
|
} elseif (! is_numeric($plantCode)) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Plant code '{$plantCode}' should contain only numeric values!",
|
'status_description' => "Plant code '{$plantCode}' should contain only numeric values!",
|
||||||
|
'status_response' => (object) [],
|
||||||
], 404);
|
], 404);
|
||||||
} elseif (Str::length($plantCode) < 4 || Str::length($plantCode) > 7) {
|
} elseif (Str::length($plantCode) < 4 || Str::length($plantCode) > 7) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Plant code '{$plantCode}' must be between 4 and 7 digits only!",
|
'status_description' => "Plant code '{$plantCode}' must be between 4 and 7 digits only!",
|
||||||
|
'status_response' => (object) [],
|
||||||
], 404);
|
], 404);
|
||||||
} elseif (! preg_match('/^[1-9]\d{3,6}$/', $plantCode)) {
|
} elseif (! preg_match('/^[1-9]\d{3,6}$/', $plantCode)) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Invalid plant code '{$plantCode}' found!",
|
'status_description' => "Invalid plant code '{$plantCode}' found!",
|
||||||
|
'status_response' => (object) [],
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($serialNumbers == null || $serialNumbers == '' || ! $serialNumbers) {
|
if (empty($serialNumbers) || ! is_array($serialNumbers) || count($serialNumbers) == 0) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Serial numbers can't be empty!",
|
'status_description' => 'Serial numbers is required and must be a non-empty array.',
|
||||||
|
'status_response' => (object) [],
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,18 +548,25 @@ class TestingPanelController extends Controller
|
|||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Plant code '{$plantCode}' not found!",
|
'status_description' => "Plant code '{$plantCode}' not found!",
|
||||||
], 400);
|
'status_response' => (object) [],
|
||||||
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$plantId = $plant->id;
|
$plantId = $plant->id;
|
||||||
|
|
||||||
$serialArray = array_map('trim', explode(',', $serialNumbers));
|
// $serialArray = array_map('trim', explode(',', $serialNumbers));
|
||||||
// $serialNumber = 'SNO-'.Str::random(5).'-'.time(); // Default random serial number if not provided
|
// // $serialNumber = 'SNO-'.Str::random(5).'-'.time(); // Default random serial number if not provided
|
||||||
|
|
||||||
|
$serialArray = $serialNumbers;
|
||||||
|
|
||||||
// Remove null, empty string, or falsy values from $serialArray
|
// Remove null, empty string, or falsy values from $serialArray
|
||||||
$serialArray = array_filter($serialArray, function ($serial) {
|
// $serialArray = array_filter($serialArray, function ($serial) {
|
||||||
return $serial != null && $serial != '' && $serial;
|
// return $serial != null && $serial != '' && $serial;
|
||||||
});
|
// });
|
||||||
|
// Remove null/empty/falsy and reindex the array
|
||||||
|
$serialArray = array_values(array_filter($serialNumbers, function ($serial) {
|
||||||
|
return $serial != null && $serial != '' && is_string($serial) && trim($serial) != '';
|
||||||
|
}));
|
||||||
|
|
||||||
$serialStatus = [];
|
$serialStatus = [];
|
||||||
$validSerials = [];
|
$validSerials = [];
|
||||||
@@ -586,7 +601,8 @@ class TestingPanelController extends Controller
|
|||||||
if ($validSerials == null || empty($validSerials)) {
|
if ($validSerials == null || empty($validSerials)) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_descriptions' => $serialStatus,
|
'status_description' => 'Has pending leak test!',
|
||||||
|
'status_response' => [$serialStatus],
|
||||||
], 404);
|
], 404);
|
||||||
} else {
|
} else {
|
||||||
$serialArray = $validSerials; // nonExistingSerials
|
$serialArray = $validSerials; // nonExistingSerials
|
||||||
@@ -604,7 +620,8 @@ class TestingPanelController extends Controller
|
|||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_descriptions' => $mergedResult,
|
'status_description' => 'Has pending leak test!',
|
||||||
|
'status_response' => [$mergedResult],
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -629,14 +646,16 @@ class TestingPanelController extends Controller
|
|||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => $hasFail ? 'ERROR' : 'SUCCESS',
|
'status_code' => $hasFail ? 'ERROR' : 'SUCCESS',
|
||||||
'status_descriptions' => $mergedResult,
|
'status_description' => $hasFail ? 'Has pending leak test!' : 'Each serial number has passed the leak test!',
|
||||||
|
'status_response' => [$mergedResult],
|
||||||
], $hasFail ? 404 : 200);
|
], $hasFail ? 404 : 200);
|
||||||
} else {
|
} else {
|
||||||
$mergedResult = $serialStatus + $nonExistingSerials + $existingSerials; // nonExistingSerials
|
$mergedResult = $serialStatus + $nonExistingSerials + $existingSerials; // nonExistingSerials
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_descriptions' => $mergedResult,
|
'status_description' => 'Has pending leak test!',
|
||||||
|
'status_response' => [$mergedResult],
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ Route::post('testing/reading/store-data', [TestingPanelController::class, 'store
|
|||||||
|
|
||||||
Route::post('testing/leak-test/store-data', [TestingPanelController::class, 'storeLeakTestStatus']);
|
Route::post('testing/leak-test/store-data', [TestingPanelController::class, 'storeLeakTestStatus']);
|
||||||
|
|
||||||
Route::get('testing/leak-test/get-data', [TestingPanelController::class, 'getLeakTestStatus']);
|
Route::post('testing/leak-test/get-data', [TestingPanelController::class, 'getLeakTestStatus']);
|
||||||
|
|
||||||
Route::get('get-pdf', [PdfController::class, 'getPdf']); // processorder/get-pdf
|
Route::get('get-pdf', [PdfController::class, 'getPdf']); // processorder/get-pdf
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user