<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "fix_out_of_stock_list".
 *
 * @property integer $id
 * @property string $name
 * @property integer $brand_id
 * @property integer $series_id
 * @property integer $displacement_id
 * @property string $car_year
 * @property string $created_at
 * @property string $updated_at
 *
 * @property DisplacementT $displacement
 * @property SeriesT $series
 * @property BrandT $brand
 */
class FixOutOfStockList extends \common\models\Base
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'fix_out_of_stock_list';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['brand_id', 'series_id', 'displacement_id'], 'integer'],
            [['created_at', 'updated_at'], 'safe'],
            [['name'], 'string', 'max' => 100],
            [['car_year'], 'string', 'max' => 50],
            [['name'], 'unique'],
            [['displacement_id'], 'exist', 'skipOnError' => true, 'targetClass' => DisplacementT::className(), 'targetAttribute' => ['displacement_id' => 'id']],
            [['series_id'], 'exist', 'skipOnError' => true, 'targetClass' => SeriesT::className(), 'targetAttribute' => ['series_id' => 'id']],
            [['brand_id'], 'exist', 'skipOnError' => true, 'targetClass' => BrandT::className(), 'targetAttribute' => ['brand_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'brand_id' => 'Brand ID',
            'series_id' => 'Series ID',
            'displacement_id' => 'Displacement ID',
            'car_year' => 'Car Year',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }

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

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

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