diff --git a/app/Http/Controllers/MachineController.php b/app/Http/Controllers/MachineController.php new file mode 100644 index 0000000..208f6cf --- /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) + { + // + } +}