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.
50 lines
1011 B
50 lines
1011 B
<?php |
|
|
|
namespace common\modules\forms\forms; |
|
|
|
use common\modules\forms\entities\FormMessage; |
|
use yii\base\Model; |
|
use yii\data\ActiveDataProvider; |
|
|
|
class FormMessageSearch extends Model |
|
{ |
|
public $id; |
|
public $form_id; |
|
|
|
public function rules(): array |
|
{ |
|
return [ |
|
[['id', 'form_id'], 'integer'], |
|
]; |
|
} |
|
|
|
/** |
|
* @param array $params |
|
* @return ActiveDataProvider |
|
*/ |
|
public function search(array $params): ActiveDataProvider |
|
{ |
|
$query = FormMessage::find(); |
|
|
|
$dataProvider = new ActiveDataProvider([ |
|
'query' => $query, |
|
'sort' => [ |
|
'defaultOrder' => ['id' => SORT_DESC] |
|
] |
|
]); |
|
|
|
$this->load($params); |
|
|
|
if (!$this->validate()) { |
|
$query->where('0=1'); |
|
return $dataProvider; |
|
} |
|
|
|
$query->andFilterWhere([ |
|
'id' => $this->id, |
|
'form_id' => $this->form_id |
|
]); |
|
|
|
return $dataProvider; |
|
} |
|
}
|
|
|