@php $command = ''; if(isset($httpMethod) && strcmp(strtoupper($httpMethod), 'GET') !== 0) $command = '--request '.$httpMethod; $command .= ' --header "client-token: api-mfr-0123456789abcdef0123456789ABCDEF"'; if(isset($userToken)) $command .= ' --header "user-token: '.$userToken.'"'; $command .= ' --header "content-type: Application/JSON"'; if(isset($requestJSONBody)) { $command .= ' -d {'; $commandParameterCount = 0; $requestJSONProcessedString = str_replace(array("\r", "\n", " "), '', $requestJSONBody); $decodedBodyParams = json_decode($requestJSONProcessedString, true); // dd($decodedBodyParams); foreach($decodedBodyParams as $key => $param) { if($commandParameterCount > 0) $command .= ', '; if(!is_array($param)) $command .= '"'.$key.'": "'.$param.'"'; else { $subCounter = 0; $command .= '"'.$key.'": {'; foreach($param as $subParamKey => $subParam) { if($subCounter > 0) $command .=', '; $command .= '"'.$subParamKey.'": "'.$subParam.'"'; $subCounter++; } $command .= '}'; } $commandParameterCount++; } $command .= '}'; } @endphp curl {{ $command }} {{ $requestURL }}