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) { // } }