FIX date add customer

main
nocode 1 year ago
parent c2651d0830
commit fbbb065965
  1. 10
      Modules/Agents/Services/AgentService.php

@ -70,9 +70,15 @@ class AgentService
$agentIdBelonging = $isInAgentDistance[0]->agent_id;
$customerAgentAllTime = $this->modelCustomer->byPhone($dataInput['phone'])->orderBy('created_at','asc')->get();
if(!empty($customerAgentAllTime[0])){
$differenceInDays = $today->diffInDays($customerAgentAllTime[0]->created_at);
// $differenceInDays = $today->diffInDays($customerAgentAllTime[0]->created_at);
$dateNow = Carbon::create($today->year, $today->month, $today->day); // current date
$datecurrent = Carbon::create($customerAgentAllTime[0]->created_at->year, $customerAgentAllTime[0]->created_at->month, $customerAgentAllTime[0]->created_at->day); // Ngày muốn trừ
$differenceInDays = $dateNow->diffInDays($datecurrent);
// dd($today, $customerAgentAllTime[0]->created_at, $differenceInDays);
if($differenceInDays > self::DISTANCE_DAY_DEFAULT){
$dataInsert['agent_id'] = $agentId;
$this->modelCustomer->insert($dataInsert);

Loading…
Cancel
Save