Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Madan_Para's avatar

How to find the requests coming in an API controller function ?

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 !

0 likes
2 replies
SilenceBringer's avatar

@madan_para you can go step-by-step in your code (starting from defined api route) to see if you will end up in this function.

or test it by returning test response and see it in postman

	public function sync_scheduled_sessions(Request $request)
    { 
        return response()->json([
            'status'  => true,
            'message'   => "I'm here!",
        ]);

Please or to participate in this conversation.