Skip to content

Commit

Permalink
Исключаем некоторые поля из генерации правил
Browse files Browse the repository at this point in the history
['created_at', 'updated_at', 'created_by', 'updated_by']

Настраиваемое значение $exceptFieldRules в генераторе
  • Loading branch information
carono committed Mar 5, 2018
1 parent a9fff04 commit b51531e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions generators/model/BaseGenerator.php
Expand Up @@ -15,6 +15,7 @@
*/
class BaseGenerator extends \yii\gii\generators\model\Generator
{
public $exceptFieldRules = ['created_at', 'updated_at', 'created_by', 'updated_by'];
/**
* @var null string for the table prefix, which is ignored in generated class name
*/
Expand Down Expand Up @@ -355,6 +356,13 @@ public function generateRules($table)
{
$columns = [];

foreach ($table->columns as $index => $column) {
if (in_array($column->name, $this->exceptFieldRules)) {
$columns[$index] = $column;
unset($table->columns[$index]);
}
}

$rules = [];

//for enum fields create rules "in range" for all enum values
Expand Down

0 comments on commit b51531e

Please sign in to comment.