public function get_all_questions_where_in($ids_array) { $question = Questions::whereIn('questions.id', $ids_array)->leftJoin('answers', 'questions.id', '=', 'answers.question_id')->selectRaw('questions.*, count(answers.id) as total_answers')->groupBy('questions.id')->get(); // ->toSql(); // print_r($question); // die; if (count($question) > 0) { return $question; } else { return ""; } }