for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace roaresearch\yii2\formgenerator\roa\models;
use roaresearch\yii2\roa\ResourceSearch;
use yii\data\ActiveDataProvider;
/**
* Contract to filter and sort collections of `Field` records.
* @author Angel (Faryshta) Guevara <[email protected]>
*/
class FieldSearch extends Field implements ResourceSearch
{
* @inhertidoc
protected function slugBehaviorConfig(): array
return [
'idAttribute' => [],
'resourceName' => 'field',
];
}
public function rules()
[['data_type_id', 'created_by'], 'integer'],
[['name', 'label'], 'string'],
public function search(
array $params,
?string $formName = ''
): ?ActiveDataProvider {
$this->load($params, $formName);
if (!$this->validate()) {
return null;
$class = get_parent_class();
return new ActiveDataProvider([
'query' => $class::find()->andFilterWhere([
'created_by' => $this->created_by,
'data_type_id' => $this->data_type_id,
])
->andFilterWhere(['like', 'name', $this->name])
->andFilterWhere(['like', 'label', $this->label]),
]);