/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Notification::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'userId' => $this->userId, 'updateDate' => $this->updateDate, 'createDate' => $this->createDate]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'message', $this->message])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'params', $this->params]); return $dataProvider; }
public function actionSample() { //$objPHPExcel = new \PHPExcel(); $template = Yii::$app->util->templateExcel(); $model = new Notification(); $date = date('YmdHis'); $name = $date . Notification; //$attributes = $model->attributeLabels(); $models = Notification::find()->all(); $excelChar = Yii::$app->util->excelChar(); $not = Yii::$app->util->excelNot(); foreach ($model->attributeLabels() as $k => $v) { if (!in_array($k, $not)) { $attributes[$k] = $v; } } $objReader = \PHPExcel_IOFactory::createReader('Excel5'); $objPHPExcel = $objReader->load(Yii::getAlias($template)); return $this->render('sample', ['models' => $models, 'attributes' => $attributes, 'excelChar' => $excelChar, 'not' => $not, 'name' => $name, 'objPHPExcel' => $objPHPExcel]); }