public function sync_scheduled_sessions(Request $request)
{
$data = $request->json()->all();
$child_id = $request->header('CHILD-ID');
$user = auth('api')->user();
$user_id = $user->id;
#Get Child Informations
$get_child = Schedulesession::select('id')->where('child_id', '=', $child_id)
->where(DB::raw("(DATE_FORMAT(local_time,'%Y-%m-%d'))"),date('Y-m-d',strtotime($data['localTimestamp'])))
->where('type', '=', '1')->get()->count();
if($get_child==0){
$child = Schedulesession::create([
'child_id' => $child_id,
'sessions' => json_encode($data['scheduledSessions']),
'server_time' => date('Y-m-d H:i:s',strtotime($data['serverTimestamp'])),
'local_time' => date('Y-m-d H:i:s',strtotime($data['localTimestamp'])),
'type' => '1'
]);
}else{
$session_data = Schedulesession::where('child_id', '=', $child_id)->where('type', '=', '1')->get()->first();
if(date('Y-m-d H:i:s O',strtotime($data['serverTimestamp'])) > date('Y-m-d H:i:s O',strtotime($session_data->server_time))){
$childinfo = Schedulesession::where('child_id', '=',$child_id)->where('type', '=','1')
->update(['sessions'=> json_encode($data['scheduledSessions']),
'server_time'=> date('Y-m-d H:i:s',strtotime($data['serverTimestamp'])),
'local_time'=> date('Y-m-d H:i:s',strtotime($data['localTimestamp']))
]);
}
}
$session_list_array = array();
$session_data = Schedulesession::where('child_id', '=', $child_id)->where('type', '=', '1')->get()->first();
if(isset($session_data->id)){
$session_list_array = array('serverTimestamp'=>date('Y-m-d H:i:s O',strtotime($session_data->server_time)),'scheduledSessions'=>json_decode($session_data->sessions));
}
return response()->json([
'status' => true,
'message' => "success",
'data' => $session_list_array
]);
}
I have this code of someone else. Now, i have to run this API in postman and collect all the webservices details. But, my question is " I want to know what are the requests, it is coming to this function "? Is there any way to see that, like we use dd() in views controller. If anyone have any idea, pls share. Thank you !