| @@ 12-76 (lines=65) @@ | ||
| 9 | /** |
|
| 10 | * SearchMailTemplate represents the model behind the search form about `app\modules\mailTemplate\models\MailTemplate`. |
|
| 11 | */ |
|
| 12 | class SearchMailTemplate extends MailTemplate |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * @inheritdoc |
|
| 16 | */ |
|
| 17 | public function rules() |
|
| 18 | { |
|
| 19 | return [ |
|
| 20 | [['id'], 'integer'], |
|
| 21 | [['key', 'name'], 'string', 'max' => 255], |
|
| 22 | [['updated_at',], 'safe'], |
|
| 23 | ]; |
|
| 24 | } |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @inheritdoc |
|
| 28 | */ |
|
| 29 | public function scenarios() |
|
| 30 | { |
|
| 31 | // bypass scenarios() implementation in the parent class |
|
| 32 | return Model::scenarios(); |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * Creates data provider instance with search query applied |
|
| 37 | * |
|
| 38 | * @param array $params |
|
| 39 | * |
|
| 40 | * @return ActiveDataProvider |
|
| 41 | */ |
|
| 42 | public function search($params) |
|
| 43 | { |
|
| 44 | $query = MailTemplate::find(); |
|
| 45 | ||
| 46 | // add conditions that should always apply here |
|
| 47 | ||
| 48 | $dataProvider = new ActiveDataProvider([ |
|
| 49 | 'pagination' => [ |
|
| 50 | 'pageSize' => Yii::$app->params['grid']['itemsPrePage'], |
|
| 51 | ], |
|
| 52 | 'query' => $query, |
|
| 53 | ]); |
|
| 54 | ||
| 55 | $this->load($params); |
|
| 56 | ||
| 57 | if (!$this->validate()) { |
|
| 58 | // uncomment the following line if you do not want to return any records when validation fails |
|
| 59 | // $query->where('0=1'); |
|
| 60 | return $dataProvider; |
|
| 61 | } |
|
| 62 | ||
| 63 | // grid filtering conditions |
|
| 64 | $query->andFilterWhere([ |
|
| 65 | 'id' => $this->id, |
|
| 66 | 'updated_at' => $this->updated_at, |
|
| 67 | ]); |
|
| 68 | ||
| 69 | $query->andFilterWhere(['like', 'key', $this->key]) |
|
| 70 | ->andFilterWhere(['like', 'body', $this->body]) |
|
| 71 | ->andFilterWhere(['like', 'name', $this->name]) |
|
| 72 | ->andFilterWhere(['like', 'subject', $this->subject]); |
|
| 73 | ||
| 74 | return $dataProvider; |
|
| 75 | } |
|
| 76 | } |
|
| 77 | ||
| @@ 12-76 (lines=65) @@ | ||
| 9 | /** |
|
| 10 | * PageSearch represents the model behind the search form about `app\modules\page\models\Page`. |
|
| 11 | */ |
|
| 12 | class PageSearch extends Page |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * @inheritdoc |
|
| 16 | */ |
|
| 17 | public function rules() |
|
| 18 | { |
|
| 19 | return [ |
|
| 20 | [['id'], 'integer'], |
|
| 21 | [['key', 'title', 'content', 'description', 'created_at', 'updated_at'], 'safe'], |
|
| 22 | ]; |
|
| 23 | } |
|
| 24 | ||
| 25 | /** |
|
| 26 | * @inheritdoc |
|
| 27 | */ |
|
| 28 | public function scenarios() |
|
| 29 | { |
|
| 30 | // bypass scenarios() implementation in the parent class |
|
| 31 | return Model::scenarios(); |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * Creates data provider instance with search query applied |
|
| 36 | * |
|
| 37 | * @param array $params |
|
| 38 | * |
|
| 39 | * @return ActiveDataProvider |
|
| 40 | */ |
|
| 41 | public function search($params) |
|
| 42 | { |
|
| 43 | $query = Page::find(); |
|
| 44 | ||
| 45 | // add conditions that should always apply here |
|
| 46 | ||
| 47 | $dataProvider = new ActiveDataProvider([ |
|
| 48 | 'pagination' => [ |
|
| 49 | 'pageSize' => Yii::$app->params['grid']['itemsPrePage'], |
|
| 50 | ], |
|
| 51 | 'query' => $query, |
|
| 52 | ]); |
|
| 53 | ||
| 54 | $this->load($params); |
|
| 55 | ||
| 56 | if (!$this->validate()) { |
|
| 57 | // uncomment the following line if you do not want to return any records when validation fails |
|
| 58 | // $query->where('0=1'); |
|
| 59 | return $dataProvider; |
|
| 60 | } |
|
| 61 | ||
| 62 | // grid filtering conditions |
|
| 63 | $query->andFilterWhere([ |
|
| 64 | 'id' => $this->id, |
|
| 65 | 'created_at' => $this->created_at, |
|
| 66 | 'updated_at' => $this->updated_at, |
|
| 67 | ]); |
|
| 68 | ||
| 69 | $query->andFilterWhere(['like', 'key', $this->key]) |
|
| 70 | ->andFilterWhere(['like', 'title', $this->title]) |
|
| 71 | ->andFilterWhere(['like', 'content', $this->content]) |
|
| 72 | ->andFilterWhere(['like', 'description', $this->description]); |
|
| 73 | ||
| 74 | return $dataProvider; |
|
| 75 | } |
|
| 76 | } |
|
| 77 | ||