<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "middle_group_category".
 *
 * @property integer $id
 * @property integer $fix_group_id
 * @property integer $fix_car_category_id
 * @property string $created_at
 * @property string $updated_at
 *
 * @property FixCarCategory $fixCarCategory
 * @property FixCarGroup $fixGroup
 */
class MiddleGroupCategory extends \common\models\Base
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'middle_group_category';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['fix_group_id', 'fix_car_category_id'], 'required'],
            [['fix_group_id', 'fix_car_category_id'], 'integer'],
            [['created_at', 'updated_at'], 'safe'],
            [['fix_car_category_id'], 'exist', 'skipOnError' => true, 'targetClass' => FixCarCategory::className(), 'targetAttribute' => ['fix_car_category_id' => 'id']],
            [['fix_group_id'], 'exist', 'skipOnError' => true, 'targetClass' => FixCarGroup::className(), 'targetAttribute' => ['fix_group_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'fix_group_id' => 'Fix Group ID',
            'fix_car_category_id' => 'Fix Car Category ID',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getFixCarCategory()
    {
        return $this->hasOne(FixCarCategory::className(), ['id' => 'fix_car_category_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getFixGroup()
    {
        return $this->hasOne(FixCarGroup::className(), ['id' => 'fix_group_id']);
    }
}
