<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "middle_part_store_room".
 *
 * @property integer $id
 * @property integer $part_id
 * @property integer $store_room_id
 * @property string $created_at
 * @property string $updated_at
 *
 * @property FixCarPart $part
 * @property StoreRoom $storeRoom
 */
class MiddlePartStoreRoom extends \common\models\Base
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'middle_part_store_room';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['part_id', 'store_room_id'], 'integer'],
            [['created_at', 'updated_at'], 'safe'],
            [['part_id'], 'exist', 'skipOnError' => true, 'targetClass' => FixCarPart::className(), 'targetAttribute' => ['part_id' => 'id']],
            [['store_room_id'], 'exist', 'skipOnError' => true, 'targetClass' => StoreRoom::className(), 'targetAttribute' => ['store_room_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'part_id' => 'Part ID',
            'store_room_id' => 'Store Room ID',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }

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

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