Update API add Customer

main
nocode 1 year ago
parent 579da1e816
commit 910fa2560e
  1. 6
      Modules/Agents/Services/AgentService.php

@ -68,10 +68,8 @@ class AgentService
$dataInsert['agent_id'] = $agentId;
$result = $this->modelCustomer->insert($dataInsert);
// nếu agent id cũ != cái hiện tại check
$checkOldCustomer = $this->modelCustomer->where('phone', $dataInput['phone'])->where('agent_id', '=',$agentId)->latest()->first();
if($agentId != $checkOldCustomer->agent_id){
$this->modelCustomer->where('phone', $dataInput['phone'])->where('agent_id', '<>',$agentId)->where('created_at', '<=', $dateNotToo)->delete();
}
$this->modelCustomer->where('phone', $dataInput['phone'])->where('agent_id', '<>',$agentId)->delete();
}
\DB::commit();

Loading…
Cancel
Save