Yii2 Bootstrap 3
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.
 
 

72 lines
1.6 KiB

<?php
/**
* This is the template for generating the model class of a specified table.
*
* @var yii\base\View $this
* @var yii\gii\generators\model\Generator $generator
* @var string $tableName full table name
* @var string $className class name
* @var yii\db\TableSchema $tableSchema
* @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)
*/
echo "<?php\n";
?>
namespace <?= $generator->ns ?>;
/**
* This is the model class for table "<?= $tableName ?>".
*
<?php foreach ($tableSchema->columns as $column): ?>
* @property <?= "{$column->phpType} \${$column->name}\n" ?>
<?php endforeach; ?>
<?php if (!empty($relations)): ?>
*
<?php foreach ($relations as $name => $relation): ?>
* @property <?= $relation[1] . ($relation[2] ? '[]' : '') . ' $' . lcfirst($name) . "\n" ?>
<?php endforeach; ?>
<?php endif; ?>
*/
class <?= $className ?> extends <?= '\\' . ltrim($generator->baseClass, '\\') . "\n" ?>
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '<?= $tableName ?>';
}
/**
* @inheritdoc
*/
public function rules()
{
return [<?= "\n\t\t\t" . implode(",\n\t\t\t", $rules) . "\n\t\t" ?>];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
<?php foreach ($labels as $name => $label): ?>
<?= "'$name' => '" . addslashes($label) . "',\n" ?>
<?php endforeach; ?>
];
}
<?php foreach ($relations as $name => $relation): ?>
/**
* @return \yii\db\ActiveRelation
*/
public function get<?= $name ?>()
{
<?= $relation[0] . "\n" ?>
}
<?php endforeach; ?>
}