Your IP : 216.73.216.79


Current Path : /var/www/html/dosm/backend/modules/statisticsFun/models/
Upload File :
Current File : /var/www/html/dosm/backend/modules/statisticsFun/models/StatsFunMainSearch.php

<?php

namespace backend\modules\statisticsFun\models;

use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\statisticsFun\models\StatsFunMain;

/**
 * StatsFunMainSearch represents the model behind the search form of `backend\modules\statisticsFun\models\StatsFunMain`.
 */
class StatsFunMainSearch extends StatsFunMain {

    /**
     * {@inheritdoc}
     */
    public function rules() {
        return [
            [['stats_id'], 'integer'],
            [['stats_slug', 'stats_title', 'stats_thumbnail', 'stats_background', 'created_at', 'created_by', 'updated_at', 'updated_by', 
                'stats_status', 'stats_descr','stats_new_label','sorting'], '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 = StatsFunMain::find();

        // add conditions that should always apply here

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

        $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;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'stats_id' => $this->stats_id,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
        ]);

        $query->andFilterWhere(['like', 'stats_slug', $this->stats_slug])
                ->andFilterWhere(['like', 'stats_title', $this->stats_title])
                ->andFilterWhere(['like', 'stats_status', $this->stats_status])
                ->andFilterWhere(['like', 'stats_descr', $this->stats_descr])
                ->andFilterWhere(['=', 'stats_new_label', $this->stats_new_label])
                ->andFilterWhere(['like', 'sorting', $this->sorting]);

        return $dataProvider;
    }

}