<?php

namespace common\models;

use Yii;
use yii\db\ActiveRecord;

/**
 * This is the model class for table "middle_fix_car_t".
 *
 * @property integer $id
 * @property integer $fix_id
 * @property integer $type
 * @property integer $status
 *
 * @property FixCarT $fix
 */
class MiddleFixCarT extends ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'middle_fix_car_t';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['fix_id', 'type', 'status'], 'integer'],
            [['fix_id'], 'exist', 'skipOnError' => true, 'targetClass' => FixCarT::className(), 'targetAttribute' => ['fix_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'fix_id' => 'Fix ID',
            'type' => 'Type',
            'status' => 'Status',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getFix()
    {
        return $this->hasOne(FixCarT::className(), ['id' => 'fix_id']);
    }
    public function getItems(){
        return $this->hasMany(FixCarItemT::className(),['fix_id'=>'fix_id']);
    }
}
