76 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			76 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?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']);
 | |
|     }
 | |
| }
 | 
