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