diff --git a/Modules/Agents/Services/AgentService.php b/Modules/Agents/Services/AgentService.php index e490a4e..d2e8911 100644 --- a/Modules/Agents/Services/AgentService.php +++ b/Modules/Agents/Services/AgentService.php @@ -157,6 +157,15 @@ class AgentService $myAgentDown->onlyGrant($input['grant']); } $listAgentGet = $myAgentDown->get(); + $allAgentInGeneral = $this->modelAgentUser->byAgentRoot($agentId)->joinAgent()->get(); + + $AgentById = []; + if(!empty($allAgentInGeneral)){ + foreach($allAgentInGeneral as $vAgent){ + $AgentById[$vAgent->agent_id] = $vAgent; + } + } + if (!empty($listAgentGet)) { $listAgentById = []; foreach ($listAgentGet as $kAgent) { @@ -169,8 +178,8 @@ class AgentService if (!empty($listAgentById)) { foreach ($listAgentById as $vByAgent) { - if (!empty($listAgentById[$vByAgent->grant_parent_id])) { - $agentParent = $listAgentById[$vByAgent->grant_parent_id]; + if (!empty($AgentById[$vByAgent->grant_parent_id])) { + $agentParent = $AgentById[$vByAgent->grant_parent_id]; $upGrant = $agentParent->code ?? null; } if ($agentId == $vByAgent->agent_id)