add new fields
This commit is contained in:
parent
5e2bc02bb5
commit
43557838ac
@ -3,6 +3,8 @@
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\Expression;
|
||||
|
||||
/**
|
||||
* This is the model class for table "company".
|
||||
@ -27,6 +29,18 @@ class Company extends \yii\db\ActiveRecord
|
||||
return 'company';
|
||||
}
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'class' => TimestampBehavior::class,
|
||||
'createdAtAttribute' => 'created_at',
|
||||
'updatedAtAttribute' => 'updated_at',
|
||||
'value' => new Expression('NOW()'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -14,6 +14,12 @@ use yii\db\Expression;
|
||||
* @property string $description
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
* @property string $budget
|
||||
* @property int $company_id
|
||||
*
|
||||
* @property FieldsValue[] $fieldsValues
|
||||
* @property Company $company
|
||||
* @property ProjectUser[] $projectUsers
|
||||
*/
|
||||
class Project extends \yii\db\ActiveRecord
|
||||
{
|
||||
@ -47,6 +53,8 @@ class Project extends \yii\db\ActiveRecord
|
||||
[['description'], 'string'],
|
||||
[['created_at', 'updated_at'], 'safe'],
|
||||
[['name'], 'string', 'max' => 255],
|
||||
[['budget'], 'string', 'max' => 100],
|
||||
[['company_id'], 'exist', 'skipOnError' => true, 'targetClass' => Company::class, 'targetAttribute' => ['company_id' => 'id']],
|
||||
];
|
||||
}
|
||||
|
||||
@ -61,6 +69,32 @@ class Project extends \yii\db\ActiveRecord
|
||||
'description' => 'Описание',
|
||||
'created_at' => 'Дата создания',
|
||||
'updated_at' => 'Дата редактирования',
|
||||
'budget' => 'Бюджет',
|
||||
'company_id' => 'Компания',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getFieldsValues()
|
||||
{
|
||||
return $this->hasMany(FieldsValue::class, ['project_id' => 'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getCompany()
|
||||
{
|
||||
return $this->hasOne(Company::class, ['id' => 'company_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getProjectUsers()
|
||||
{
|
||||
return $this->hasMany(ProjectUser::class, ['project_id' => 'id']);
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ use yii\db\Expression;
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
* @property string $resume
|
||||
* @property string $salary
|
||||
*
|
||||
* @property array $genders
|
||||
* @property string $gendersText
|
||||
@ -62,6 +63,7 @@ class UserCard extends \yii\db\ActiveRecord
|
||||
[['gender'], 'in', 'range' => array_keys($this->genders)],
|
||||
[['dob', 'created_at', 'updated_at'], 'safe'],
|
||||
[['fio', 'passport', 'photo', 'email', 'resume'], 'string', 'max' => 255],
|
||||
[['salary'], 'string', 'max' => 100],
|
||||
[['status'], 'exist', 'skipOnError' => true, 'targetClass' => Status::class, 'targetAttribute' => ['status' => 'id']],
|
||||
];
|
||||
}
|
||||
@ -83,9 +85,26 @@ class UserCard extends \yii\db\ActiveRecord
|
||||
'created_at' => 'Дата создания',
|
||||
'updated_at' => 'Дата редактирование',
|
||||
'resume' => 'Резюме',
|
||||
'salary' => 'Зарплата',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getFieldsValues()
|
||||
{
|
||||
return $this->hasMany(FieldsValue::class, ['card_id' => 'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getProjectUsers()
|
||||
{
|
||||
return $this->hasMany(ProjectUser::class, ['card_id' => 'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m181011_142555_add_column_to_user_card
|
||||
*/
|
||||
class m181011_142555_add_column_to_user_card extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->addColumn('user_card', 'salary', $this->string(100));
|
||||
$this->addColumn('project', 'budget', $this->string(100));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropColumn('user_card', 'salary');
|
||||
$this->dropColumn('project', 'budget');
|
||||
}
|
||||
|
||||
/*
|
||||
// Use up()/down() to run migration code without a transaction.
|
||||
public function up()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m181011_142555_add_column_to_user_card cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m181011_143349_add_column_company_id_to_project_table
|
||||
*/
|
||||
class m181011_143349_add_column_company_id_to_project_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->addColumn('project', 'company_id', $this->integer(11));
|
||||
$this->addForeignKey(
|
||||
'project_ibfk_company',
|
||||
'project',
|
||||
'company_id',
|
||||
'company',
|
||||
'id',
|
||||
'RESTRICT',
|
||||
'CASCADE'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropForeignKey('project_ibfk_company', 'project');
|
||||
|
||||
$this->dropColumn('project', 'company_id');
|
||||
}
|
||||
|
||||
/*
|
||||
// Use up()/down() to run migration code without a transaction.
|
||||
public function up()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m181011_143349_add_column_company_id_to_project_table cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
Loading…
Reference in New Issue
Block a user