1
0
forked from poc/pds

Updated get func. removed plant-code header and added production-order header and changed success response

This commit is contained in:
dhanabalan
2025-06-16 12:33:48 +05:30
parent a46a5d437c
commit 16aa118ef1

View File

@@ -350,39 +350,71 @@ class ObdController extends Controller
{
return response()->json([
'status_code' => 'ERROR',
'status_description' => 'Invalid authorization token'
'status_description' => 'Invalid authorization token!'
], 403);
}
$plantCode = $request->header('plant-code');
if (empty($plantCode))
// $plantCode = $request->header('plant-code');
// if (empty($plantCode))
// {
// return response()->json([
// 'status_code' => 'ERROR',
// 'status_description' => "Plant code can't be empty"
// ], 400);
// }
// else if(Str::length($plantCode) < 4 || !is_numeric($plantCode))
// {
// return response()->json([
// 'status_code' => 'ERROR',
// 'status_description' => "Plant code should contain minimum 4 digits numeric values only!"
// ], 400);
// }
// $plantId = Plant::where('code', $plantCode)->value('id');
// if (!$plantId)
// {
// return response()->json([
// 'status_code' => 'ERROR',
// 'status_description' => "Plant code not found"
// ], 400);
// }
$productionOrder = $request->header('production-order');
if (empty($productionOrder))
{
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Plant code can't be empty"
'status_description' => "Production order can't be empty!"
], 400);
}
else if(Str::length($plantCode) < 4 || !is_numeric($plantCode))
else if(Str::length($productionOrder) < 7 || !is_numeric($productionOrder))
{
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Plant code should contain minimum 4 digits numeric values only!"
'status_description' => "Production order should contain minimum 7 digits numeric values only!"
], 400);
}
$plantId = Plant::where('code', $plantCode)->value('id');
$prodOrderExist = ($productionOrder == '1234567' || $productionOrder == '7654321');
if (!$plantId)
if (!$prodOrderExist)
{
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Plant code not found"
'status_description' => "Production order not found!"
], 400);
}
try
{
return response("Successfully GET request Received", 200)->header('Content-Type', 'text/plain');
//return response("Successfully GET request Received", 200)->header('Content-Type', 'text/plain');
$itemCode = Item::where('code', '123456')->where('plant_id', 1)->first();
return response()->json([
'item_code' => $itemCode->code,
'item_description' => $itemCode->description
], 400);
}
catch (\Exception $e)
{