$test_id, 'type' => $type,])->where('pid', '>', 0)->column('pid'); $model = self::alias('p')->join('Questions q', 'p.questions_id=q.id') ->where(['p.type' => $type, 'q.is_del' => 0]) ->whereIn('test_id', array_merge($test_ids,[$test_id])); if ($question_type) { $model = $model->where('p.question_type', $question_type); } $list = $model->field('p.*,q.option,q.stem,q.image,q.answer,q.difficulty,q.analysis,q.relation,q.is_img,q.is_del') ->order('p.sort desc')->select(); return count($list) > 0 ? $list->toArray() : []; } }