2018-10-11 11:15:09 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace common\models;
|
|
|
|
|
|
|
|
use Yii;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is the model class for table "fields_value".
|
|
|
|
*
|
|
|
|
* @property int $id
|
|
|
|
* @property int $card_id
|
|
|
|
* @property int $field_id
|
|
|
|
* @property string $value
|
|
|
|
* @property int $order
|
2018-10-11 17:24:47 +03:00
|
|
|
* @property int $project_id
|
|
|
|
* @property int $company_id
|
2018-10-11 11:15:09 +03:00
|
|
|
*
|
|
|
|
* @property AdditionalFields $field
|
2018-10-11 17:24:47 +03:00
|
|
|
* @property Company $company
|
|
|
|
* @property Project $project
|
2018-10-11 11:15:09 +03:00
|
|
|
* @property UserCard $card
|
|
|
|
*/
|
|
|
|
class FieldsValue extends \yii\db\ActiveRecord
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public static function tableName()
|
|
|
|
{
|
|
|
|
return 'fields_value';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function rules()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
[['field_id', 'value'], 'required'],
|
2018-10-11 17:24:47 +03:00
|
|
|
[['card_id', 'field_id', 'order', 'project_id', 'company_id'], 'integer'],
|
2018-10-11 11:15:09 +03:00
|
|
|
[['value'], 'string', 'max' => 255],
|
|
|
|
[['field_id'], 'exist', 'skipOnError' => true, 'targetClass' => AdditionalFields::class, 'targetAttribute' => ['field_id' => 'id']],
|
2018-10-11 17:24:47 +03:00
|
|
|
[['company_id'], 'exist', 'skipOnError' => true, 'targetClass' => Company::class, 'targetAttribute' => ['company_id' => 'id']],
|
2018-10-11 11:15:09 +03:00
|
|
|
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::class, 'targetAttribute' => ['project_id' => 'id']],
|
|
|
|
[['card_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::class, 'targetAttribute' => ['card_id' => 'id']],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function attributeLabels()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'id' => 'ID',
|
|
|
|
'card_id' => 'Card ID',
|
|
|
|
'field_id' => 'Field ID',
|
|
|
|
'value' => 'Value',
|
|
|
|
'project_id' => 'Project ID',
|
2018-10-11 17:24:47 +03:00
|
|
|
'company_id' => 'Company ID',
|
2018-10-11 11:15:09 +03:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \yii\db\ActiveQuery
|
|
|
|
*/
|
|
|
|
public function getField()
|
|
|
|
{
|
|
|
|
return $this->hasOne(AdditionalFields::class, ['id' => 'field_id']);
|
|
|
|
}
|
|
|
|
|
2018-10-11 17:24:47 +03:00
|
|
|
/**
|
|
|
|
* @return \yii\db\ActiveQuery
|
|
|
|
*/
|
|
|
|
public function getCompany()
|
|
|
|
{
|
|
|
|
return $this->hasOne(Company::className(), ['id' => 'company_id']);
|
|
|
|
}
|
|
|
|
|
2018-10-11 11:15:09 +03:00
|
|
|
/**
|
|
|
|
* @return \yii\db\ActiveQuery
|
|
|
|
*/
|
|
|
|
public function getProject()
|
|
|
|
{
|
|
|
|
return $this->hasOne(Project::class, ['id' => 'project_id']);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \yii\db\ActiveQuery
|
|
|
|
*/
|
|
|
|
public function getCard()
|
|
|
|
{
|
|
|
|
return $this->hasOne(UserCard::class, ['id' => 'card_id']);
|
|
|
|
}
|
|
|
|
}
|