2024-08-20 06:27:17 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\models;
|
|
|
|
use yii\base\Model;
|
|
|
|
use yii\data\ActiveDataProvider;
|
|
|
|
|
|
|
|
class ParameterSearch extends Parameter
|
|
|
|
{
|
|
|
|
public $id;
|
|
|
|
public $title;
|
|
|
|
|
|
|
|
public function rules()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
[[ 'id' ], 'integer' ],
|
|
|
|
[[ 'title' ], 'string' ]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function scenarios()
|
|
|
|
{
|
|
|
|
return Model::scenarios();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function search($params): ActiveDataProvider
|
|
|
|
{
|
2024-08-21 10:03:27 +02:00
|
|
|
$query = Parameter::find();
|
2024-08-20 06:27:17 +02:00
|
|
|
|
|
|
|
$dataProvider = new ActiveDataProvider([
|
|
|
|
'query' => $query,
|
|
|
|
]);
|
|
|
|
|
|
|
|
if (!($this->load($params) && $this->validate())) {
|
|
|
|
return $dataProvider;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->title) {
|
|
|
|
$query->andFilterWhere(['like', 'title', $this->title]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->id) {
|
|
|
|
$query->andFilterWhere(['like', 'id', $this->id]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $dataProvider;
|
|
|
|
}
|
|
|
|
}
|