params['subclass']) && !empty($this->params['subclass'])) $this->params['subclass'] = end($this->params['subclass']); return [ '=' => ['subclass','training_course_id', 'question_type', 'question_selects', 'question_answer', 'question_analysis'], '%like%' => ['title'], ]; } /** * @notes 获取列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2025/02/14 13:49 */ public function lists(): array { $lists = TrainingQuestions::with(['goodsCategory'])->where($this->searchWhere) ->field(['*']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select() ->toArray(); foreach ($lists as &$item) { if($item['goodsCategory']){ $item['category_id_text'] = $item['goodsCategory']['name']; $item['category_two_text'] = GoodsCategory::where('id',$item['goodsCategory']['pid']??0)->value('name')??''; $item['category_three_text'] = GoodsCategory::where('id',GoodsCategory::where('id',$item['goodsCategory']['pid'])->value('pid')??0)->value('name')??''; } } return $lists; } /** * @notes 获取数量 * @return int * @author likeadmin * @date 2025/02/14 13:49 */ public function count(): int { return TrainingQuestions::where($this->searchWhere)->count(); } }