Your IP : 216.73.216.124


Current Path : /var/www/html/chatbot/backend/models/
Upload File :
Current File : /var/www/html/chatbot/backend/models/TemplateSearch.php

<?php

namespace backend\models;

use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\models\Template;

/**
 * TemplateSearch represents the model behind the search form of `backend\models\Template`.
 */
class TemplateSearch extends Template
{
    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['dt_id', 'dt_cat'], 'integer'],
            [['dt_title', 'dt_header', 'dt_body', 'dt_footer', 'dt_type', 'dt_code', 'dt_status', 'created_by', 'created_at', 'updated_by', 'updated_at'], '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 = Template::find();

        // add conditions that should always apply here

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

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

        $query->andFilterWhere(['like', 'dt_title', $this->dt_title])
            ->andFilterWhere(['like', 'dt_header', $this->dt_header])
            ->andFilterWhere(['like', 'dt_body', $this->dt_body])
            ->andFilterWhere(['like', 'dt_footer', $this->dt_footer])
            ->andFilterWhere(['like', 'dt_type', $this->dt_type])
            ->andFilterWhere(['like', 'dt_code', $this->dt_code])
            ->andFilterWhere(['like', 'dt_status', $this->dt_status])
            ->andFilterWhere(['like', 'created_by', $this->created_by])
            ->andFilterWhere(['like', 'updated_by', $this->updated_by]);

        return $dataProvider;
    }
}