@php foreach($parentQuestions as $key => $parent) { $questionId = $parent->id; $question = $parent // $is_child = false; $childQuestion = app\Models\Question::where('polling_id',$question->polling_id)->where('parent_question',$questionId)->first(); $response = app\Models\QuestionResponse::where('id',$question->response_id)->first(); if($response!=NULL) { $arr_responses=json_decode($response->response); $response_html = $question["is_required"] == 1 && $question->is_multiple == 1 ? ' ' : ''; $i=0; foreach($arr_responses as $k => $response_name) { $response_html.='
'; } $html = '

Q'.($q_key +1).': '.$question["question"].' '.($question["is_required"] == 1 ? '*' : '').'

'.$response_html.'
'.($childQuestion ? self::pollQuestionsHTML($q_key,$childQuestion,true) : '').'
'; return $html; } else { $response_html = $question["is_required"] == 1 && $question->is_multiple == 1 ? ' ' : ''; $i=0; $response_html.='
'; $html = '

Q'.($q_key +1).': '.$question["question"].' '.($question["is_required"] == 1 ? '*' : '').'

'.$response_html.'
'.($childQuestion ? self::pollQuestionsHTML($q_key,$childQuestion,true) : '').'
'; return $html; } } @endphp