add company
This commit is contained in:
75
common/models/Company.php
Normal file
75
common/models/Company.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "company".
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $description
|
||||
* @property int $status_id
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
*
|
||||
* @property Status $status
|
||||
* @property FieldsValue[] $fieldsValues
|
||||
*/
|
||||
class Company extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'company';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name'], 'required'],
|
||||
[['description'], 'string'],
|
||||
[['status_id'], 'integer'],
|
||||
[['created_at', 'updated_at'], 'safe'],
|
||||
[['name'], 'string', 'max' => 255],
|
||||
[['status_id'], 'exist', 'skipOnError' => true, 'targetClass' => Status::className(), 'targetAttribute' => ['status_id' => 'id']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'name' => 'Название',
|
||||
'description' => 'Описание',
|
||||
'status_id' => 'Статус',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->hasOne(Status::className(), ['id' => 'status_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getFieldsValues()
|
||||
{
|
||||
return $this->hasMany(FieldsValue::className(), ['company_id' => 'id']);
|
||||
}
|
||||
}
|
@ -9,12 +9,15 @@ use Yii;
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $card_id
|
||||
* @property int $project_id
|
||||
* @property int $field_id
|
||||
* @property string $value
|
||||
* @property int $order
|
||||
* @property int $project_id
|
||||
* @property int $company_id
|
||||
*
|
||||
* @property AdditionalFields $field
|
||||
* @property Company $company
|
||||
* @property Project $project
|
||||
* @property UserCard $card
|
||||
*/
|
||||
class FieldsValue extends \yii\db\ActiveRecord
|
||||
@ -34,9 +37,10 @@ class FieldsValue extends \yii\db\ActiveRecord
|
||||
{
|
||||
return [
|
||||
[['field_id', 'value'], 'required'],
|
||||
[['card_id', 'field_id', 'order', 'project_id'], 'integer'],
|
||||
[['card_id', 'field_id', 'order', 'project_id', 'company_id'], 'integer'],
|
||||
[['value'], 'string', 'max' => 255],
|
||||
[['field_id'], 'exist', 'skipOnError' => true, 'targetClass' => AdditionalFields::class, 'targetAttribute' => ['field_id' => 'id']],
|
||||
[['company_id'], 'exist', 'skipOnError' => true, 'targetClass' => Company::class, 'targetAttribute' => ['company_id' => 'id']],
|
||||
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::class, 'targetAttribute' => ['project_id' => 'id']],
|
||||
[['card_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::class, 'targetAttribute' => ['card_id' => 'id']],
|
||||
];
|
||||
@ -53,6 +57,7 @@ class FieldsValue extends \yii\db\ActiveRecord
|
||||
'field_id' => 'Field ID',
|
||||
'value' => 'Value',
|
||||
'project_id' => 'Project ID',
|
||||
'company_id' => 'Company ID',
|
||||
];
|
||||
}
|
||||
|
||||
@ -64,6 +69,14 @@ class FieldsValue extends \yii\db\ActiveRecord
|
||||
return $this->hasOne(AdditionalFields::class, ['id' => 'field_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getCompany()
|
||||
{
|
||||
return $this->hasOne(Company::className(), ['id' => 'company_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
|
@ -20,6 +20,7 @@ class UseField extends \yii\db\ActiveRecord
|
||||
{
|
||||
const USE_PROFILE = 0;
|
||||
const USE_PROJECT = 1;
|
||||
const USE_COMPANY = 2;
|
||||
|
||||
|
||||
/**
|
||||
@ -66,7 +67,8 @@ class UseField extends \yii\db\ActiveRecord
|
||||
{
|
||||
return [
|
||||
self::USE_PROFILE => 'Профиль',
|
||||
self::USE_PROJECT => 'Проект'
|
||||
self::USE_PROJECT => 'Проект',
|
||||
self::USE_COMPANY => 'Компания'
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ class UseStatus extends \yii\db\ActiveRecord
|
||||
{
|
||||
const USE_PROFILE = 0;
|
||||
const USE_PROJECT = 1;
|
||||
const USE_COMPANY = 2;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@ -65,7 +66,8 @@ class UseStatus extends \yii\db\ActiveRecord
|
||||
{
|
||||
return [
|
||||
self::USE_PROFILE => 'Профиль',
|
||||
self::USE_PROJECT => 'Проект'
|
||||
self::USE_PROJECT => 'Проект',
|
||||
self::USE_COMPANY => 'Компания'
|
||||
];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user