Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = LogUpload::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'userCreate' => $this->userCreate, 'userUpdate' => $this->userUpdate, 'type' => $this->type]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'filename', $this->filename])->andFilterWhere(['like', 'fileori', $this->fileori])->andFilterWhere(['like', 'warning', $this->warning])->andFilterWhere(['like', 'updateDate', $this->updateDate])->andFilterWhere(['like', 'createDate', $this->createDate])->andFilterWhere(['like', 'params', $this->params]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = LogUpload::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'userId' => $this->userId, 'type' => $this->type, 'userCreate' => $this->userCreate, 'userUpdate' => $this->userUpdate, 'updateDate' => $this->updateDate, 'createDate' => $this->createDate]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'filename', $this->filename])->andFilterWhere(['like', 'fileori', $this->fileori])->andFilterWhere(['like', 'params', $this->params])->andFilterWhere(['like', 'values', $this->values])->andFilterWhere(['like', 'warning', $this->warning])->andFilterWhere(['like', 'keys', $this->keys]);
     return $dataProvider;
 }
 public function actionExcel()
 {
     $searchModel = new LogUploadSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $modelAttribute = new LogUpload();
     $not = Util::excelNot();
     foreach ($modelAttribute->attributeLabels() as $k => $v) {
         if (!in_array($k, $not)) {
             $attributes[$k] = $v;
         }
     }
     $models = $dataProvider->getModels();
     $objReader = \PHPExcel_IOFactory::createReader('Excel5');
     $objPHPExcel = $objReader->load(Yii::getAlias(Util::templateExcel()));
     $excelChar = Util::excelChar();
     return $this->render('_excel', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'attributes' => $attributes, 'models' => $models, 'objReader' => $objReader, 'objPHPExcel' => $objPHPExcel, 'excelChar' => $excelChar]);
 }