/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Messagebox::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['msg_id' => $this->msg_id, 'receiver_type' => $this->receiver_type, 'receiver' => $this->receiver]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'author', $this->author]); return $dataProvider; }
public function actionMessagebox() { $this->layout = false; $gh_id = U::getSessionParam('gh_id'); $openid = U::getSessionParam('openid'); Yii::$app->wx->setGhId($gh_id); $gh = Yii::$app->wx->getGh(); $model = MStaff::findOne(['gh_id' => $gh_id, 'openid' => $openid]); if ($model === null) { U::W(['Invalid openid.', __METHOD__, $gh_id, $openid]); return $this->redirect(['staffsearch', 'gh_id' => $gh_id, 'openid' => $openid]); } if (empty($model->office_id)) { U::W(['Invalid office_id.', __METHOD__, $gh_id, $openid]); return $this->redirect(['staffbind', 'gh_id' => $gh_id, 'openid' => $openid, 'mobile' => $model->mobile]); } $messageboxs = Messagebox::find()->where(['receiver' => $model->office_id])->orderBy(['msg_id' => SORT_DESC])->all(); return $this->render('messagebox', ['gh_id' => $gh_id, 'openid' => $openid, 'messageboxs' => $messageboxs]); }