Updated get func. removed plant-code header and added production-order header and changed success response
This commit is contained in:
@@ -350,39 +350,71 @@ class ObdController extends Controller
|
|||||||
{
|
{
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => 'Invalid authorization token'
|
'status_description' => 'Invalid authorization token!'
|
||||||
], 403);
|
], 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
$plantCode = $request->header('plant-code');
|
// $plantCode = $request->header('plant-code');
|
||||||
if (empty($plantCode))
|
// 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([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Plant code can't be empty"
|
'status_description' => "Production order can't be empty!"
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
else if(Str::length($plantCode) < 4 || !is_numeric($plantCode))
|
else if(Str::length($productionOrder) < 7 || !is_numeric($productionOrder))
|
||||||
{
|
{
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'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);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$plantId = Plant::where('code', $plantCode)->value('id');
|
$prodOrderExist = ($productionOrder == '1234567' || $productionOrder == '7654321');
|
||||||
|
|
||||||
if (!$plantId)
|
if (!$prodOrderExist)
|
||||||
{
|
{
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Plant code not found"
|
'status_description' => "Production order not found!"
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
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)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user