Skip to content

Instantly share code, notes, and snippets.

@nutch31
Created March 4, 2019 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nutch31/3f91a53ffe0f2b9b40824fba2779b76c to your computer and use it in GitHub Desktop.
Save nutch31/3f91a53ffe0f2b9b40824fba2779b76c to your computer and use it in GitHub Desktop.
/**
* Get All Lead Forms
*
* @param request analyticCampaignId
* @param optional page, limit
*/
public function Response_getCampaignWidget($input)
{
$response = array();
$request->didPhone[] = $input["overAllUniqueLeadsDidPhone"];
$request->startDateTime = $input["overAllUniqueLeadsStartDate"];
$request->endDateTime = $input["overAllUniqueLeadsEndDate"];
$param = app()->make('App\Http\Controllers\Api\CallController');
$res = $param->Reponse_getCalls_DidPhoneArray_Unique(
$request
);
return $res;
}
public function Reponse_getCalls_DidPhoneArray_Unique(Request $request)
{
$response = array();
$count = DB::table('calls')
->join('channels', 'channels.channel_id', '=', 'calls.channel_id')
->whereIn('channels.tracking_phone', $request->didPhone)
->where('is_duplicated', '=', '0')
->whereBetween('calls.date', [$request->startDateTime, $request->endDateTime]);
if(isset($request->status))
{
$count = $count->where('calls.status', '=', $request->status);
}
$count = $count->count();
$dt = Carbon::createFromFormat('Y-m-d H:i:s', $request->startDateTime);
//$dt->setTimezone($this->timezone);
$StartDateTime = $dt->format(DateTime::ISO8601);
$dt2 = Carbon::createFromFormat('Y-m-d H:i:s', $request->endDateTime);
//$dt2->setTimezone($this->timezone);
$EndDateTime = $dt2->format(DateTime::ISO8601);
$response['fromDateTime'] = "$StartDateTime";
$response['totalUniqueCalls'] = "$count";
$response['toDateTime'] = "$EndDateTime";
//$response = json_encode($response);
return $response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment