$result = array("AgentData" => $AgentResult, "AgentLogs" => $LogsResult); if ($AgentResult) { $response->json(Result::success('', $result)); } else { $response->json(Result::error('Agent not found')); } } }); $this->respond(['GET', 'POST'], '/edit/[:id]', function ($request, $response, $service, $app) { $id = $request->param('id'); $data = json_decode($request->body(), true); // Access only for Current Agent if (!Agents::isAdmin() && !Agents::isCurrentAgent($id)) { $response->json(Result::error('Access is denied')); } else { $result = Agents::updateAgent($id, $data); if ($result > 0) { $response->json(Result::success('Agent Updated.')); } elseif ($result === 0) { $response->json(Result::success('Agent not Updated.')); } else { $response->json(Result::error('Agent not found')); } } }); $this->respond(['GET', 'POST'], '/edit/password/[:id]', function ($request, $response, $service) { $id = $request->param('id'); $oldPassword = $request->param('oldPassword', ''); $newPassword = $request->param('newPassword', ''); // Access only for Current Agent if (!Agents::isAdmin() && !Agents::isCurrentAgent($id)) {