You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.1 KiB
66 lines
1.1 KiB
7 years ago
|
<?php
|
||
|
/**
|
||
|
* Created by Error202
|
||
|
* Date: 04.06.2018
|
||
|
*/
|
||
|
|
||
|
namespace backend\forms;
|
||
|
|
||
|
|
||
|
use core\entities\Settings;
|
||
|
use yii\base\Model;
|
||
|
use yii\data\ActiveDataProvider;
|
||
|
|
||
|
class SettingsSearch extends Settings
|
||
|
{
|
||
|
public $id;
|
||
|
public $type;
|
||
|
public $section;
|
||
|
public $key;
|
||
|
public $value;
|
||
|
public $active;
|
||
|
|
||
|
public function rules()
|
||
|
{
|
||
|
return [
|
||
|
[['id'], 'integer'],
|
||
|
[['active'], 'boolean'],
|
||
|
[['type', 'section', 'key', 'value'], 'safe'],
|
||
|
];
|
||
|
}
|
||
|
/**
|
||
|
* @return array
|
||
|
*/
|
||
|
public function scenarios()
|
||
|
{
|
||
|
// bypass scenarios() implementation in the parent class
|
||
|
return Model::scenarios();
|
||
|
}
|
||
|
/**
|
||
|
* @param $params
|
||
|
* @return ActiveDataProvider
|
||
|
*/
|
||
|
public function search($params)
|
||
|
{
|
||
|
$query = Settings::find();
|
||
|
$dataProvider = new ActiveDataProvider(
|
||
|
[
|
||
|
'query' => $query,
|
||
|
]
|
||
|
);
|
||
|
if (!($this->load($params) && $this->validate())) {
|
||
|
return $dataProvider;
|
||
|
}
|
||
|
$query->andFilterWhere(
|
||
|
[
|
||
|
'id' => $this->id,
|
||
|
'active' => $this->active,
|
||
|
'section' => $this->section,
|
||
|
]
|
||
|
);
|
||
|
$query->andFilterWhere(['like', 'key', $this->key])
|
||
|
->andFilterWhere(['like', 'value', $this->value]);
|
||
|
return $dataProvider;
|
||
|
}
|
||
|
|
||
|
}
|