diff --git a/app/Http/Controllers/Api/AuthApiController.php b/app/Http/Controllers/Api/AuthApiController.php index 5d6edc7..7b83319 100755 --- a/app/Http/Controllers/Api/AuthApiController.php +++ b/app/Http/Controllers/Api/AuthApiController.php @@ -57,8 +57,8 @@ class AuthApiController extends BaseAuthApiController // Agent User Root $agentRootInfo = Agent::find($agentUser->agent_root_id); $agentUserRoot = AgentUser::where('agent_id', $agentUser->agent_root_id)->where('agent_root_id', $agentUser->agent_root_id)->latest()->first(); - - + + } if (!empty($agentUser->agent_id)) { // Agent User Current @@ -114,12 +114,18 @@ class AuthApiController extends BaseAuthApiController $dataInsert = $this->transformRegisterData($request->all()); if (!empty($dataInsert)) { + if (!empty($checkUserAgent->agent_id)) { + $agentParent = Agent::find($checkUserAgent->agent_id); + $grantParent = $agentParent->grant; + } + $userId = \App\Models\User::insertGetId($dataInsert); if ($userId) { $dataAgentInsert = [ 'name' => $dataInsert['name'] ?? '', 'type' => self::AGENTS, - 'grant' => $this->_default_grant_two, + // 'grant' => $this->_default_grant_two, + 'grant' => !empty($grantParent)?$grantParent+1:1, 'phone' => $dataInsert['phone'] ?? '', 'address' => $dataInsert['address'] ?? '', ];