Skip to content

Commit

Permalink
Merge pull request #909 from bakaphp/feat-agent-owner-id
Browse files Browse the repository at this point in the history
feat: agent owner id
  • Loading branch information
kaioken committed Feb 8, 2024
2 parents f516f22 + db58b32 commit f5ac906
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Domains/Connectors/Zoho/Workflows/ZohoAgentActivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,13 @@ public function execute(Model $user, AppInterface $app, array $params): array
protected function createAgent(AppInterface $app, ZohoService $zohoService, UserInterface $user, Companies $company): array
{
try {
$sponsorsPage = $company->get('sponsors_page') ?? [];
$userInvite = UsersInvite::fromCompany($company)->fromApp($app)->where('email', $user->email)->firstOrFail();
$agentOwner = Agent::fromCompany($company)->where('users_id', $userInvite->users_id)->firstOrFail();
$agentPage = $user->get('agent_website');
$agentPageUserId = $sponsorsPage[$agentPage] ?? false;

$agentOwnerUserId = $agentPageUserId ?? $userInvite->users_id;
$agentOwner = Agent::fromCompany($company)->where('users_id', $agentOwnerUserId)->firstOrFail();
$ownerInfo = $zohoService->getAgentByMemberNumber((string) $agentOwner->member_id);

$ownerId = $ownerInfo->Owner['id'];
Expand Down

0 comments on commit f5ac906

Please sign in to comment.