Your IP : 216.73.216.79


Current Path : /var/www/html/audit/backend/modules/theme/models/
Upload File :
Current File : /var/www/html/audit/backend/modules/theme/models/ThemeRuleSearch.php

<?php

namespace backend\modules\theme\models;

use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\theme\models\ThemeRule;

/**
 * ThemeRuleSearch represents the model behind the search form of `backend\modules\theme\models\ThemeRule`.
 */
class ThemeRuleSearch extends ThemeRule {

    /**
     * {@inheritdoc}
     */
    public function rules() {
        return [
            [['rule_id', 'rule_status', 'created_by', 'updated_by'], 'integer'],
            [['rule_name', 'rule_content', 'rule_params', 'created_at', 'updated_at','rule_description'], 'safe'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function scenarios() {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params) {
        $query = ThemeRule::find();

        // add conditions that should always apply here

        $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10,]]);
        $dataProvider->setSort(['defaultOrder' => ['rule_id' => SORT_DESC]]);


        $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(['like', 'rule_name', $this->rule_name])
                ->andFilterWhere(['like', 'rule_description', $this->rule_description])
                ->andFilterWhere(['=', 'rule_status', $this->rule_status]);

        return $dataProvider;
    }

}