Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 27 |
| SurveyQuestionSearch | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
30.00 | |
0.00% |
0 / 27 |
| rules | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 6 |
|||
| scenarios | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
| search | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 18 |
|||
| <?php | |
| namespace backend\models; | |
| use Yii; | |
| use yii\base\Model; | |
| use yii\data\ActiveDataProvider; | |
| use common\models\SurveyQuestion; | |
| /** | |
| * SurveyQuestionSearch represents the model behind the search form about `common\models\SurveyQuestion`. | |
| */ | |
| class SurveyQuestionSearch extends SurveyQuestion | |
| { | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function rules() | |
| { | |
| return [ | |
| [['type'], 'integer'], | |
| [['content'], '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 = null) | |
| { | |
| if($query === null){ | |
| $query = SurveyQuestion::find() | |
| ->orderBy('[[on]] ASC'); | |
| } | |
| $dataProvider = new ActiveDataProvider([ | |
| 'query' => $query, | |
| ]); | |
| $this->load($params); | |
| if (!$this->validate()) { | |
| // uncomment the following line if you do not want to any records when validation fails | |
| // $query->where('0=1'); | |
| return $dataProvider; | |
| } | |
| $query->andFilterWhere([ | |
| 'type' => $this->type, | |
| ]); | |
| $query->andFilterWhere(['like', 'content', $this->content]); | |
| return $dataProvider; | |
| } | |
| } |