1], [['limit'], 'default', 'value' => 20], ]; } public function search() { $query = Comment::find()->alias('c') ->select('c.id,c.level,c.content,c.created_at,u.nickname,u.avatar_url,u.mobile_phone,ut.nickname as to_nickname,ut.avatar_url as to_avatar_url,ut.mobile_phone as to_mobile_phone,s.name as store_name') ->leftJoin(['u' => User::tableName()],'c.user_id=u.id') ->leftJoin(['ut' => User::tableName()],'c.to_user_id=ut.id') ->leftJoin(['s' => Store::tableName()],'c.store_id=s.id') ->where(['c.is_delete' => 0]) ->andFilterWhere(['c.store_id' => $this->store_id]) ->andFilterWhere([ 'OR', ['like','u.nickname',$this->keywords], ['like','ut.nickname',$this->keywords], ['like','s.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['created_at_cn'] = date("Y-m-d H:i",$item['created_at']); $item['mobile_phone'] = EncryptHelper::decryptMobilePhone($item['mobile_phone']); $item['to_mobile_phone'] = EncryptHelper::decryptMobilePhone($item['to_mobile_phone']); $list[$index] = $item; } $data = []; $data['code'] = 0; $data['msg'] = 'ok'; $data['data'] = $list; $data['count'] = $count; return $data; } }