Commit 3ea63437 by Qiang Xue

improved search model [skip ci]

parent b23cb177
...@@ -25,6 +25,7 @@ echo "<?php\n"; ...@@ -25,6 +25,7 @@ echo "<?php\n";
namespace <?= StringHelper::dirname(ltrim($generator->searchModelClass, '\\')) ?>; namespace <?= StringHelper::dirname(ltrim($generator->searchModelClass, '\\')) ?>;
use Yii; use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;
use <?= ltrim($generator->modelClass, '\\') . (isset($modelAlias) ? " as $modelAlias" : "") ?>; use <?= ltrim($generator->modelClass, '\\') . (isset($modelAlias) ? " as $modelAlias" : "") ?>;
...@@ -41,6 +42,12 @@ class <?= $searchModelClass ?> extends <?= isset($modelAlias) ? $modelAlias : $m ...@@ -41,6 +42,12 @@ class <?= $searchModelClass ?> extends <?= isset($modelAlias) ? $modelAlias : $m
]; ];
} }
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
public function search($params) public function search($params)
{ {
$query = <?= isset($modelAlias) ? $modelAlias : $modelClass ?>::find(); $query = <?= isset($modelAlias) ? $modelAlias : $modelClass ?>::find();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment