bedezign\yii2\audit\models\AuditTrailSearch::search PHP Метод

    public function search($params, $query = null)
    {
        $query = $query ? $query : $this->find();
        $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
        // load the search form data and validate
        if (!($this->load($params) && $this->validate())) {
            return $dataProvider;
        }
        // adjust the query by adding the filters
        $userId = $this->user_id;
        if (strlen($this->user_id)) {
            $userId = intval($this->user_id) ?: 0;
        }
        $query->andFilterWhere(['id' => $this->id]);
        $query->andFilterWhere(['entry_id' => $this->entry_id]);
        $query->andFilterWhere(['user_id' => $userId]);
        $query->andFilterWhere(['action' => $this->action]);
        $query->andFilterWhere(['like', 'model', $this->model]);
        $query->andFilterWhere(['model_id' => $this->model_id]);
        if (is_array($this->field)) {
            $query->andFilterWhere(['in', 'field', $this->field]);
        } else {
            $query->andFilterWhere(['field' => $this->field]);
        }
        $query->andFilterWhere(['like', 'created', $this->created]);
        return $dataProvider;
    }

Usage Example

Пример #1
0
 /**
  * @inheritdoc
  */
 public function getDetail()
 {
     $searchModel = new AuditTrailSearch();
     $params = \Yii::$app->request->getQueryParams();
     $params['AuditTrailSearch']['entry_id'] = $params['id'];
     $dataProvider = $searchModel->search($params);
     return \Yii::$app->view->render('panels/trail/detail', ['panel' => $this, 'dataProvider' => $dataProvider, 'searchModel' => $searchModel]);
 }
All Usage Examples Of bedezign\yii2\audit\models\AuditTrailSearch::search