1], [['limit'], 'default', 'value' => 20], ]; } public function search() { $query = Detection::find()->alias('d') ->select('d.*,u.real_name,u.avatar_url,u.mobile_phone as phone') ->leftJoin(['u' => User::tableName()],'d.user_id=u.id') ->where([ 'd.is_delete' => 0 ]) ->andFilterWhere(['d.store_id' => $this->store_id]) ->andFilterWhere([ 'OR', ['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(['d.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']); $item['avatar_url_cn'] = SiteHelper::getFullUrl($item['avatar_url']); $list[$index] = $item; } $data = []; $data['code'] = 0; $data['msg'] = 'ok'; $data['data'] = $list; $data['count'] = $count; return $data; } }