shopId]; if(isset($this->params['keyword']) && $this->params['keyword']){ $where[] = ['keyword','like','%'.$this->params['keyword'].'%']; } return $where; } public function lists(): array { $lists = Coach::where($this->setWhere()) ->field('id,name,good_comment,work_photo,order_num,location') ->limit($this->limitOffset, $this->limitLength) ->select() ->toArray(); // $ids = array_column($lists,'coach_id'); // $skillIds = array_column($lists,'skill_id'); // $skillLists = Skill::where(['id'=>$skillIds])->column('name','id'); foreach ($lists as $key => $coach){ $lists[$key]['good_comment'] = $coach['good_comment'].'%'; // $lists[$key]['skill_name'] = $skillLists[$coach['skill_id']] ?? ''; } return $lists; } public function count(): int { return Coach::where($this->setWhere()) ->count(); } }