modelClass); $searchModelClass = StringHelper::basename($generator->searchModelClass); if ($modelClass === $searchModelClass) { $modelAlias = $modelClass . 'Model'; } $rules = $generator->generateSearchRules(); $labels = $generator->generateSearchLabels(); $searchAttributes = $generator->getSearchAttributes(); $searchConditions = $generator->generateSearchConditions(); echo " namespace searchModelClass, '\\')) ?>; use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; use modelClass, '\\') . (isset($modelAlias) ? " as $modelAlias" : "") ?>; /** * represents the model behind the search form about `modelClass ?>`. */ class extends { /** * @inheritdoc */ public function rules() { return [ , ]; } /** * @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 = ::find(); $dataProvider = new ActiveDataProvider([ 'query' => $query, ]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } return $dataProvider; } }