Commit 36c59dce by Alexander Makarov

Adjusted search model code generated by Gii CRUD generator

parent 06fdb797
...@@ -400,10 +400,10 @@ class Generator extends \yii\gii\Generator ...@@ -400,10 +400,10 @@ class Generator extends \yii\gii\Generator
case Schema::TYPE_TIME: case Schema::TYPE_TIME:
case Schema::TYPE_DATETIME: case Schema::TYPE_DATETIME:
case Schema::TYPE_TIMESTAMP: case Schema::TYPE_TIMESTAMP:
$conditions[] = "\$this->addFilter(\$query, '{$column}');"; $conditions[] = "\$query->andFilter(['{$column}' => \$this->{$column}]);";
break; break;
default: default:
$conditions[] = "\$this->addFilter(\$query, '{$column}', true);"; $conditions[] = "\$this->addFilter(['like', '{$column}', \$this->{$column}]);";
break; break;
} }
} }
......
...@@ -70,23 +70,4 @@ class <?= $searchModelClass ?> extends Model ...@@ -70,23 +70,4 @@ class <?= $searchModelClass ?> extends Model
return $dataProvider; return $dataProvider;
} }
protected function addCondition($query, $attribute, $partialMatch = false)
{
if (($pos = strrpos($attribute, '.')) !== false) {
$modelAttribute = substr($attribute, $pos + 1);
} else {
$modelAttribute = $attribute;
}
$value = $this->$modelAttribute;
if (trim($value) === '') {
return;
}
if ($partialMatch) {
$query->andWhere(['like', $attribute, $value]);
} else {
$query->andWhere([$attribute => $value]);
}
}
} }
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