public function graphheheByDate(Request $request, $companyID)
{
$companyID = $this->decode($companyID);
$matchs = DiraChatLog::whereBetween('date_access', [$request->from, $request->to])->orderBy('date_access', 'asc')->get();
foreach ($matchs as $key => $match) {
$time = strtotime($match->date_access);
$newformat = date('Y-m-d',$time);
$a[$newformat] = $this->testing($newformat,$match);
}
dd($a);
$user = array_values($a);
$dates = array_keys($a);
// dd($user, $dates);
$from = $request->from;
$to = $request->to;
// dd($from, $to);
$companyID = $this->encodeID($companyID);
return view('AltHr.Chatbot.graphhehe', compact('companyID','from','to', 'dates'))->with('user',json_encode($user,JSON_NUMERIC_CHECK))->with('dates',json_encode($dates,JSON_NUMERIC_CHECK));
}
private function testing($date,$match)
{
$a = Carbon::parse($date)->addDay()->toDateTimeString();
// dd($a,$date);
$noOfUsers = DiraChatLog::whereBetween('date_access', [$date,$a])->get();
// dd($noOfUsers);
return $noOfUsers->groupBy('user_id')->count();
}
I have done this function where it will return me with an array like date => value
so at this function. it is returning the date from the database as Y-M-D
so it is what returns to the views too. But how can I change the format of the date to D-M-Y
in either the controller or the views?