You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.6 KiB
73 lines
1.6 KiB
11 years ago
|
<?php
|
||
|
/**
|
||
|
* This is the template for generating the model class of a specified table.
|
||
11 years ago
|
*
|
||
11 years ago
|
* @var yii\web\View $this
|
||
11 years ago
|
* @var yii\gii\generators\model\Generator $generator
|
||
11 years ago
|
* @var string $tableName full table name
|
||
|
* @var string $className class name
|
||
11 years ago
|
* @var yii\db\TableSchema $tableSchema
|
||
11 years ago
|
* @var string[] $labels list of attribute labels (name=>label)
|
||
|
* @var string[] $rules list of validation rules
|
||
|
* @var array $relations list of relations (name=>relation declaration)
|
||
11 years ago
|
*/
|
||
11 years ago
|
|
||
|
echo "<?php\n";
|
||
11 years ago
|
?>
|
||
11 years ago
|
|
||
11 years ago
|
namespace <?= $generator->ns ?>;
|
||
11 years ago
|
|
||
|
/**
|
||
11 years ago
|
* This is the model class for table "<?= $tableName ?>".
|
||
11 years ago
|
*
|
||
11 years ago
|
<?php foreach ($tableSchema->columns as $column): ?>
|
||
11 years ago
|
* @property <?= "{$column->phpType} \${$column->name}\n" ?>
|
||
11 years ago
|
<?php endforeach; ?>
|
||
11 years ago
|
<?php if (!empty($relations)): ?>
|
||
|
*
|
||
|
<?php foreach ($relations as $name => $relation): ?>
|
||
11 years ago
|
* @property <?= $relation[1] . ($relation[2] ? '[]' : '') . ' $' . lcfirst($name) . "\n" ?>
|
||
11 years ago
|
<?php endforeach; ?>
|
||
|
<?php endif; ?>
|
||
11 years ago
|
*/
|
||
11 years ago
|
class <?= $className ?> extends <?= '\\' . ltrim($generator->baseClass, '\\') . "\n" ?>
|
||
11 years ago
|
{
|
||
|
/**
|
||
11 years ago
|
* @inheritdoc
|
||
11 years ago
|
*/
|
||
11 years ago
|
public static function tableName()
|
||
11 years ago
|
{
|
||
11 years ago
|
return '<?= $tableName ?>';
|
||
11 years ago
|
}
|
||
|
|
||
|
/**
|
||
11 years ago
|
* @inheritdoc
|
||
11 years ago
|
*/
|
||
11 years ago
|
public function rules()
|
||
|
{
|
||
11 years ago
|
return [<?= "\n\t\t\t" . implode(",\n\t\t\t", $rules) . "\n\t\t" ?>];
|
||
11 years ago
|
}
|
||
|
|
||
|
/**
|
||
11 years ago
|
* @inheritdoc
|
||
11 years ago
|
*/
|
||
11 years ago
|
public function attributeLabels()
|
||
|
{
|
||
11 years ago
|
return [
|
||
11 years ago
|
<?php foreach ($labels as $name => $label): ?>
|
||
11 years ago
|
<?= "'$name' => '" . addslashes($label) . "',\n" ?>
|
||
11 years ago
|
<?php endforeach; ?>
|
||
11 years ago
|
];
|
||
11 years ago
|
}
|
||
11 years ago
|
<?php foreach ($relations as $name => $relation): ?>
|
||
|
|
||
|
/**
|
||
|
* @return \yii\db\ActiveRelation
|
||
|
*/
|
||
11 years ago
|
public function get<?= $name ?>()
|
||
11 years ago
|
{
|
||
11 years ago
|
<?= $relation[0] . "\n" ?>
|
||
11 years ago
|
}
|
||
|
<?php endforeach; ?>
|
||
11 years ago
|
}
|