add equipment_type objects
This commit is contained in:
parent
e87adb36fd
commit
43618764a4
68
common/models/EventEquipmentType.php
Normal file
68
common/models/EventEquipmentType.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "event_equipment_type".
|
||||
*
|
||||
* @property integer $id
|
||||
* @property string $name
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
*
|
||||
* @property EventEquipmentTypeAssignment[] $eventEquipmentTypeAssignments
|
||||
* @property EventRegistrationEquipmentTypeAssignment[] $eventRegistrationEquipmentTypeAssignments
|
||||
*/
|
||||
class EventEquipmentType extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'event_equipment_type';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['created_at', 'updated_at'], 'required'],
|
||||
[['created_at', 'updated_at'], 'safe'],
|
||||
[['name'], 'string', 'max' => 255]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => Yii::t('common/event', 'ID'),
|
||||
'name' => Yii::t('common/event', 'Name'),
|
||||
'created_at' => Yii::t('common/event', 'Created At'),
|
||||
'updated_at' => Yii::t('common/event', 'Updated At'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getEventEquipmentTypeAssignments()
|
||||
{
|
||||
return $this->hasMany(EventEquipmentTypeAssignment::className(), ['id_event_equipment_type' => 'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getEventRegistrationEquipmentTypeAssignments()
|
||||
{
|
||||
return $this->hasMany(EventRegistrationEquipmentTypeAssignment::className(), ['id_event_equipment_type' => 'id']);
|
||||
}
|
||||
}
|
||||
72
common/models/EventEquipmentTypeAssignment.php
Normal file
72
common/models/EventEquipmentTypeAssignment.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "event_equipment_type_assignment".
|
||||
*
|
||||
* @property integer $id
|
||||
* @property integer $id_event
|
||||
* @property integer $id_event_equipment_type
|
||||
* @property integer $count
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
*
|
||||
* @property Event $idEvent
|
||||
* @property EventEquipmentType $idEventEquipmentType
|
||||
*/
|
||||
class EventEquipmentTypeAssignment extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'event_equipment_type_assignment';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id_event', 'id_event_equipment_type', 'count'], 'integer'],
|
||||
[['created_at', 'updated_at'], 'required'],
|
||||
[['created_at', 'updated_at'], 'safe']
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => Yii::t('common/event', 'ID'),
|
||||
'id_event' => Yii::t('common/event', 'Id Event'),
|
||||
'id_event_equipment_type' => Yii::t('common/event', 'Id Event Equipment Type'),
|
||||
'count' => Yii::t('common/event', 'Count'),
|
||||
'created_at' => Yii::t('common/event', 'Created At'),
|
||||
'updated_at' => Yii::t('common/event', 'Updated At'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getIdEvent()
|
||||
{
|
||||
return $this->hasOne(Event::className(), ['id' => 'id_event']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getIdEventEquipmentType()
|
||||
{
|
||||
return $this->hasOne(EventEquipmentType::className(), ['id' => 'id_event_equipment_type']);
|
||||
}
|
||||
}
|
||||
70
common/models/EventRegistrationEquipmentTypeAssignment.php
Normal file
70
common/models/EventRegistrationEquipmentTypeAssignment.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "event_registration_equipment_type_assignment".
|
||||
*
|
||||
* @property integer $id
|
||||
* @property integer $id_event_equipment_type
|
||||
* @property integer $id_event_registration
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
*
|
||||
* @property EventRegistration $idEventRegistration
|
||||
* @property EventEquipmentType $idEventEquipmentType
|
||||
*/
|
||||
class EventRegistrationEquipmentTypeAssignment extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'event_registration_equipment_type_assignment';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id_event_equipment_type', 'id_event_registration'], 'integer'],
|
||||
[['created_at', 'updated_at'], 'required'],
|
||||
[['created_at', 'updated_at'], 'safe']
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => Yii::t('common/event', 'ID'),
|
||||
'id_event_equipment_type' => Yii::t('common/event', 'Id Event Equipment Type'),
|
||||
'id_event_registration' => Yii::t('common/event', 'Id Event Registration'),
|
||||
'created_at' => Yii::t('common/event', 'Created At'),
|
||||
'updated_at' => Yii::t('common/event', 'Updated At'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getIdEventRegistration()
|
||||
{
|
||||
return $this->hasOne(EventRegistration::className(), ['id' => 'id_event_registration']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getIdEventEquipmentType()
|
||||
{
|
||||
return $this->hasOne(EventEquipmentType::className(), ['id' => 'id_event_equipment_type']);
|
||||
}
|
||||
}
|
||||
75
console/migrations/m200911_200200_add_table_equipment.php
Normal file
75
console/migrations/m200911_200200_add_table_equipment.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m200911_200200_add_table_equipment
|
||||
*/
|
||||
class m200911_200200_add_table_equipment extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$tableOptions = null;
|
||||
if ($this->db->driverName === 'mysql') {
|
||||
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
|
||||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
|
||||
}
|
||||
$this->createTable('{{%event_equipment_type}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'name' => $this->string(255),
|
||||
'created_at' => $this->dateTime()->notNull(),
|
||||
'updated_at' => $this->dateTime()->notNull(),
|
||||
], $tableOptions);
|
||||
|
||||
$this->createTable('{{%event_equipment_type_assignment}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'id_event' => $this->integer(),
|
||||
'id_event_equipment_type' => $this->integer(),
|
||||
'count' => $this->integer(),
|
||||
'created_at' => $this->dateTime()->notNull(),
|
||||
'updated_at' => $this->dateTime()->notNull(),
|
||||
'FOREIGN KEY (id_event) REFERENCES event (id) ON DELETE CASCADE ON UPDATE CASCADE',
|
||||
'FOREIGN KEY (id_event_equipment_type) REFERENCES event_equipment_type (id) ON DELETE CASCADE ON UPDATE CASCADE',
|
||||
], $tableOptions);
|
||||
|
||||
$this->createTable('{{%event_registration_equipment_type_assignment}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'id_event_equipment_type' => $this->integer(),
|
||||
'id_event_registration' => $this->integer(),
|
||||
'created_at' => $this->dateTime()->notNull(),
|
||||
'updated_at' => $this->dateTime()->notNull(),
|
||||
'FOREIGN KEY (id_event_registration) REFERENCES event_registration (id) ON DELETE CASCADE ON UPDATE CASCADE',
|
||||
'FOREIGN KEY (id_event_equipment_type) REFERENCES event_equipment_type (id) ON DELETE CASCADE ON UPDATE CASCADE',
|
||||
|
||||
], $tableOptions);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
echo "m200911_200200_add_table_equipment cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use up()/down() to run migration code without a transaction.
|
||||
public function up()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m200911_200200_add_table_equipment cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user