Your IP : 216.73.216.79


Current Path : /var/www/html/mtdc/backend/models/ContactMeta/
Upload File :
Current File : /var/www/html/mtdc/backend/models/ContactMeta/ContactMetaSearch.php

<?php

namespace backend\models\ContactMeta;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\models\ContactMeta\ContactMeta;

/**
 * ContactMetaSearch represents the model behind the search form of `backend\models\ContactMeta\ContactMeta`.
 */
class ContactMetaSearch extends ContactMeta
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['contact_meta_id', 'contact_mobile'], 'integer'],
            [['contact_name', 'contact_email', 'contact_address', 'contact_jawatan', 'contact_department', 'created_dt'], '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 = ContactMeta::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([
            'contact_meta_id' => $this->contact_meta_id,
            'contact_mobile' => $this->contact_mobile,
        ]);

        $query->andFilterWhere(['like', 'contact_name', $this->contact_name])
            ->andFilterWhere(['like', 'contact_email', $this->contact_email])
            ->andFilterWhere(['like', 'contact_address', $this->contact_address])
            ->andFilterWhere(['like', 'contact_jawatan', $this->contact_jawatan])
            ->andFilterWhere(['like', 'contact_department', $this->contact_department])
            ->andFilterWhere(['like', 'created_dt', $this->created_dt]);

        return $dataProvider;
    }
}