Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
66.67% |
2 / 3 |
CRAP | |
81.82% |
9 / 11 |
| ActivityAreaSearch | |
0.00% |
0 / 1 |
|
66.67% |
2 / 3 |
6.22 | |
81.82% |
9 / 11 |
| rules | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| scenarios | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| search | |
0.00% |
0 / 1 |
4.18 | |
77.78% |
7 / 9 |
|||
| <?php | |
| namespace backend\models; | |
| use Yii; | |
| use yii\base\Model; | |
| use yii\data\ActiveDataProvider; | |
| use common\models\ActivityArea; | |
| /** | |
| * ActivityAreaSearch represents the model behind the search form about `common\models\ActivityArea`. | |
| */ | |
| class ActivityAreaSearch extends ActivityArea | |
| { | |
| public $parent_id = false; | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function rules() | |
| { | |
| return [ | |
| [['name'], '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 = ActivityArea::find(); | |
| if ($this->parent_id !== false) { | |
| $query = $query->where(['parent_id' => $this->parent_id]); | |
| } | |
| $dataProvider = new ActiveDataProvider([ | |
| 'query' => $query, | |
| ]); | |
| if (!($this->load($params) && $this->validate())) { | |
| return $dataProvider; | |
| } | |
| $query->andFilterWhere(['like', 'name', $this->name]); | |
| return $dataProvider; | |
| } | |
| } |