84 lines
2.4 KiB
PHP
84 lines
2.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace backend\modules\forum\models;
|
||
|
|
|
||
|
|
use yii\base\Model;
|
||
|
|
use yii\data\ActiveDataProvider;
|
||
|
|
use common\models\ForumThread;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* ForumThreadSearch represents the model behind the search form of `common\models\ForumThread`.
|
||
|
|
*/
|
||
|
|
class ForumThreadSearch extends ForumThread
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* {@inheritdoc}
|
||
|
|
*/
|
||
|
|
public function rules()
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
[['id', 'forum_category_id', /*'status',*/ 'created_at', 'updated_at'], 'integer'],
|
||
|
|
[['name', 'description', 'thread_by', 'thread_tel', 'thread_email', 'thread_contact', 'remark'], '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 = ForumThread::find();
|
||
|
|
|
||
|
|
// add conditions that should always apply here
|
||
|
|
|
||
|
|
$dataProvider = new ActiveDataProvider([
|
||
|
|
'query' => $query,
|
||
|
|
'sort' => [
|
||
|
|
'defaultOrder' => [
|
||
|
|
'id' => SORT_DESC
|
||
|
|
]
|
||
|
|
]
|
||
|
|
]);
|
||
|
|
|
||
|
|
$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([
|
||
|
|
'id' => $this->id,
|
||
|
|
'forum_category_id' => $this->forum_category_id,
|
||
|
|
/*'status' => $this->status,*/
|
||
|
|
'created_at' => $this->created_at,
|
||
|
|
'updated_at' => $this->updated_at,
|
||
|
|
]);
|
||
|
|
|
||
|
|
$query->andFilterWhere(['like', 'name', $this->name])
|
||
|
|
->andFilterWhere(['like', 'description', $this->description])
|
||
|
|
->andFilterWhere(['like', 'thread_by', $this->thread_by])
|
||
|
|
->andFilterWhere(['like', 'thread_tel', $this->thread_tel])
|
||
|
|
->andFilterWhere(['like', 'thread_email', $this->thread_email])
|
||
|
|
->andFilterWhere(['like', 'thread_contact', $this->thread_contact])
|
||
|
|
->andFilterWhere(['like', 'remark', $this->remark]);
|
||
|
|
|
||
|
|
return $dataProvider;
|
||
|
|
}
|
||
|
|
}
|