Your IP : 216.73.216.79


Current Path : /var/www/html/learn/backend/models/frontendtheme/
Upload File :
Current File : /var/www/html/learn/backend/models/frontendtheme/FrontendThemeSearch.php

<?php

namespace backend\models\frontendtheme;

use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\models\frontendtheme\FrontendTheme;

/**
 * FrontendThemeSearch represents the model behind the search form of `backend\models\frontendtheme\FrontendTheme`.
 */
class FrontendThemeSearch extends FrontendTheme
{
    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['theme_id', 'header_id', 'footer_id'], 'integer'],
            [['title', 'description', 'header_description', 'footer_description','theme_setup', 'created_at', '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 = FrontendTheme::find()
        ->joinWith('footer')
        ->joinWith('header');

        // 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([
            'theme_id' => $this->theme_id,
            'header_id' => $this->header_id,
            'footer_id' => $this->footer_id,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
        ]);

        $query->andFilterWhere(['like', 'title', $this->title])
            ->andFilterWhere(['like', 'description', $this->description])
            ->andFilterWhere(['like', 'footer_description', $this->footer_description])
            ->andFilterWhere(['like', 'header_description', $this->header_description])
            ->andFilterWhere(['like', 'theme_setup', $this->theme_setup]);

        return $dataProvider;
    }
}