1], [['limit'], 'default', 'value' => 20], ]; } public function search() { $query = Coach::find()->alias('c') ->select('c.*,u.real_name,u.mobile_phone as phone') ->leftJoin(['u' => User::tableName()],'c.user_id=u.id') ->where([ 'c.is_delete' => 0 ]) ->andFilterWhere(['c.status' => $this->status]) ->andFilterWhere(['c.store_id' => $this->store_id]) ->andFilterWhere([ 'OR', ['like','c.mobile_phone',$this->keywords], ['like','c.title',$this->keywords], ['like','c.number',$this->keywords], ['like','u.real_name',$this->keywords], ]); $count = $query->count(); $pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]); $list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['c.created_at' => SORT_DESC])->asArray()->all(); foreach ($list as $index => $item){ $item['store_name'] = '未绑定'; $store = Store::findOne([ 'id' => $item['store_id'], 'is_delete' => 0 ]); if(!empty($store)){ $item['store_name'] = $store->name; } $item['created_at_cn'] = date("Y-m-d H:i",$item['created_at']); $item['phone'] = EncryptHelper::decryptMobilePhone($item['phone']); $list[$index] = $item; } $data = []; $data['code'] = 0; $data['msg'] = 'ok'; $data['data'] = $list; $data['count'] = $count; return $data; } }