diff --git a/Modules/Agents/Services/AgentService.php b/Modules/Agents/Services/AgentService.php index 0ff21cd..7622e5f 100644 --- a/Modules/Agents/Services/AgentService.php +++ b/Modules/Agents/Services/AgentService.php @@ -61,20 +61,24 @@ class AgentService $isInAgentDistance = $this->modelCustomer->byPhone($dataInput['phone'])->whereDate('created_at', '>', $dateNotToo)->orderBy('created_at','asc')->get(); // dd(empty($isInAgentDistance[0])); if (empty($isInAgentDistance[0])) { // ko co trong DS 15 ngay + dd(1); $dataInsert['agent_id'] = $agentId; $this->modelCustomer->insert($dataInsert); $this->modelCustomer->byPhone($dataInput['phone'])->notAgent($agentId)->delete(); } else { // co DS 15 ngay $agentIdBelonging = $isInAgentDistance[0]->agent_id; - if($agentIdBelonging == $agentId){ - $idAgentInsert = $agentIdBelonging; - }else{ - $idAgentInsert = $agentId; - $this->modelCustomer->byPhone($dataInput['phone'])->notAgent($agentIdBelonging)->delete(); - } - $dataInsert['agent_id'] = $idAgentInsert; + // if($agentIdBelonging == $agentId){ + // $idAgentInsert = $agentIdBelonging; + // }else{ + // $idAgentInsert = $agentId; + // $this->modelCustomer->byPhone($dataInput['phone'])->notAgent($agentIdBelonging)->delete(); + // } + $idAgentInsert = $agentId; + + $dataInsert['agent_id'] = $agentIdBelonging; $this->modelCustomer->insert($dataInsert); + $this->modelCustomer->byPhone($dataInput['phone'])->notAgent($agentIdBelonging)->delete(); }