public function search($params) { $query = Log::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'handle_id' => $this->handle_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'user_name', $this->user_name])->andFilterWhere(['like', 'user_ip', $this->user_ip])->andFilterWhere(['like', 'user_agent', $this->user_agent])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'controller', $this->controller])->andFilterWhere(['like', 'action', $this->action])->andFilterWhere(['like', 'result', $this->result])->andFilterWhere(['like', 'describe', $this->describe]); return $dataProvider; }
/** * Returns data provider with filled models. Filter applied if needed. * * @param array $params an array of parameter values indexed by parameter names * @return \yii\data\ActiveDataProvider */ public function search($params) { $query = Log::find(); $dataProvider = Log::getDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['level' => $this->level]); $query->andFilterWhere(['like', Log::tableName() . '.category', $this->category]); $query->andFilterWhere(['like', Log::tableName() . '.message', $this->message]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Log::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]); if ($this->created_at) { $date = explode(' - ', $this->created_at); if (count($date) == 2) { $query->andFilterWhere(['>=', $this::tableName() . '.created_at', $date[0] . ' 00:00:00']); $query->andFilterWhere(['<=', $this::tableName() . '.created_at', $date[1] . ' 23:59:59']); } } $query->andFilterWhere(['like', 'role', $this->role])->andFilterWhere(['like', 'action', $this->action])->andFilterWhere(['like', 'result', $this->result])->andFilterWhere(['like', 'note', $this->note]); return $dataProvider; }
/** * Displays a single System model. * @param integer $id * @return mixed */ public function actionLog() { $dataProvider = new ActiveDataProvider(['query' => Log::find()->orderBy(['id' => SORT_DESC]), 'pagination' => ['pageSize' => 20]]); return $this->render('log', ['dataProvider' => $dataProvider]); }