Class schmunk42\giiant\generators\model\Generator

Inheritanceschmunk42\giiant\generators\model\Generator » yii\gii\generators\model\Generator
Available since version0.0.1

This generator will generate one or multiple ActiveRecord classes for the specified database table.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$baseClassSuffix string Suffix to append to the base model, setting "Base" will result in a model named "PostBase" schmunk42\giiant\generators\model\Generator
$baseTraits string Base-traits schmunk42\giiant\generators\model\Generator
$generateModelClass bool Whether to overwrite (extended) model classes, will be always created, if file does not exist schmunk42\giiant\generators\model\Generator
$languageCodeColumn string The column name where the language code is stored. schmunk42\giiant\generators\model\Generator
$languageTableName string The name of the table containing the translations. schmunk42\giiant\generators\model\Generator
$singularEntities schmunk42\giiant\generators\model\Generator
$tableNameMap array Key-value pairs for mapping a table-name to class-name, eg. schmunk42\giiant\generators\model\Generator
$tablePrefix null String for the table prefix, which is ignored in generated class name schmunk42\giiant\generators\model\Generator
$useTranslatableBehavior bool Whether to use or not 2amigos/yii2-translateable-behavior schmunk42\giiant\generators\model\Generator

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$classNames2 schmunk42\giiant\generators\model\Generator

Property Details

$baseClassSuffix public property

Suffix to append to the base model, setting "Base" will result in a model named "PostBase"

$baseTraits public property

Base-traits

public string $baseTraits null
$classNames2 protected property
protected $classNames2 null
$generateModelClass public property

Whether to overwrite (extended) model classes, will be always created, if file does not exist

public bool $generateModelClass false
$languageCodeColumn public property

The column name where the language code is stored.

public string $languageCodeColumn "language"
$languageTableName public property

The name of the table containing the translations. {{table}} will be replaced with the value in "Table Name" field.

public string $languageTableName "{{table}}_lang"
$singularEntities public property
public $singularEntities false
$tableNameMap public property

Key-value pairs for mapping a table-name to class-name, eg. 'prefix_FOObar' => 'FooBar'

public array $tableNameMap = []
$tablePrefix public property

String for the table prefix, which is ignored in generated class name

public null $tablePrefix null
$useTranslatableBehavior public property

Whether to use or not 2amigos/yii2-translateable-behavior

public bool $useTranslatableBehavior true

Method Details

attributeLabels() public method

public void attributeLabels ( )
extractTranslations() protected method

protected array extractTranslations ( $tableName, $relations )
$tableName
$relations

All database's relations.

return array

Associative array containing the extracted relations and the modified translations.

generate() public method

public void generate ( )
generateClassName() public method

Generates a class name from the specified table name.

public string generateClassName ( $tableName, $useSchemaName null )
$tableName string

The table name (which may contain schema prefix)

$useSchemaName
return string

The generated class name

generateRelationName() public method

public void generateRelationName ( $relations, $table, $key, $multiple )
$relations
$table
$key
$multiple
generateRelations() protected method

protected void generateRelations ( )
generateRules() public method

Generates validation rules for the specified table and add enum value validation.

public array generateRules ( $table )
$table \yii\db\TableSchema

The table schema

return array

The generated validation rules

getDescription() public method

public void getDescription ( )
getEnum() public method

Prepare ENUM field values

public array getEnum ( $columns )
$columns array
getName() public method

public void getName ( )
getTableNames() public method

public void getTableNames ( )
hints() public method

public void hints ( )
isEnum() public method

Validate is ENUM

public \schmunk42\giiant\generators\model\type isEnum ( $column )
$column

Table column

requiredTemplates() public method

public void requiredTemplates ( )
rules() public method

public void rules ( )