Commit 1e098ebd by Qiang Xue

simplified search model [skip ci]

parent f747768f
...@@ -25,17 +25,15 @@ echo "<?php\n"; ...@@ -25,17 +25,15 @@ 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" : "") ?>;
/** /**
* <?= $searchModelClass ?> represents the model behind the search form about `<?= $generator->modelClass ?>`. * <?= $searchModelClass ?> represents the model behind the search form about `<?= $generator->modelClass ?>`.
*/ */
class <?= $searchModelClass ?> extends Model class <?= $searchModelClass ?> extends <?= isset($modelAlias) ? $modelAlias : $modelClass ?>
{
public $<?= implode(";\n public $", $searchAttributes) ?>;
{
public function rules() public function rules()
{ {
return [ return [
...@@ -43,21 +41,10 @@ class <?= $searchModelClass ?> extends Model ...@@ -43,21 +41,10 @@ class <?= $searchModelClass ?> extends Model
]; ];
} }
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
<?php foreach ($labels as $name => $label): ?>
<?= "'$name' => " . $generator->generateString($label) . ",\n" ?>
<?php endforeach; ?>
];
}
public function search($params) public function search($params)
{ {
$query = <?= isset($modelAlias) ? $modelAlias : $modelClass ?>::find(); $query = $this->find();
$dataProvider = new ActiveDataProvider([ $dataProvider = new ActiveDataProvider([
'query' => $query, 'query' => $query,
]); ]);
......
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