From ba48c1307e34e879adc71df6492ca40e28d49052 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Thu, 3 Jul 2025 15:13:59 +0530 Subject: [PATCH] Added machine controller file --- app/Http/Controllers/MachineController.php | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 app/Http/Controllers/MachineController.php diff --git a/app/Http/Controllers/MachineController.php b/app/Http/Controllers/MachineController.php new file mode 100644 index 000000000..208f6cfe9 --- /dev/null +++ b/app/Http/Controllers/MachineController.php @@ -0,0 +1,73 @@ +header('Authorization'); + $expectedToken = $expectedUser . ':' . $expectedPw; + + if ("Bearer " . $expectedToken !== $header_auth) + { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => 'Invalid authorization token' + ], 403); + } + + $machines = Machine::with('plant')->with('line')->orderBy('plant_id')->get(); + $machinesData = $machines->map(function($machine) { + return [ + 'plant_code' => $machine->plant ? (String)$machine->plant->code : "", + 'group_work_center' => $machine->line->group_work_center ?? "", + 'work_center' => $machine->work_center ?? "", + ]; + }); + + return response()->json([ + 'machines' => $machinesData + ]); + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, string $id) + { + // + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(string $id) + { + // + } +}