/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = OperationLog::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(['op_id' => $this->op_id, 'user_id' => $this->user_id, 'op_sub_type' => $this->op_sub_type, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'op_nickname', $this->op_nickname])->andFilterWhere(['like', 'op_ip', $this->op_ip])->andFilterWhere(['like', 'op_useragent', $this->op_useragent])->andFilterWhere(['like', 'op_sql', $this->op_sql])->andFilterWhere(['like', 'op_type', $this->op_type])->andFilterWhere(['like', 'op_des', $this->op_des])->orderBy(['created_at' => SORT_DESC]); return $dataProvider; }
/** * Finds the OperationLog model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return OperationLog the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = OperationLog::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }