diff --git a/app/Http/Controllers/ObdController.php b/app/Http/Controllers/ObdController.php index c0e164fd8..2d5eff429 100644 --- a/app/Http/Controllers/ObdController.php +++ b/app/Http/Controllers/ObdController.php @@ -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) {