<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "fix_car_price_b".
 *
 * @property integer $id
 * @property integer $displacement_id
 * @property string $year
 * @property integer $price
 * @property string $oil_use
 * @property string $oil_model
 * @property string $created_at
 * @property string $updated_at
 *
 * @property DisplacementT $displacement
 */
class FixCarPriceB extends \common\models\Base
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'fix_car_price_b';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['displacement_id', 'price'], 'integer'],
            [['year'], 'required'],
            [['created_at', 'updated_at'], 'safe'],
            [['year'], 'string', 'max' => 4],
            [['oil_use'], 'string', 'max' => 10],
            [['oil_model'], 'string', 'max' => 50],
            [['displacement_id'], 'exist', 'skipOnError' => true, 'targetClass' => DisplacementT::className(), 'targetAttribute' => ['displacement_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'displacement_id' => 'Displacement ID',
            'year' => 'Year',
            'price' => 'Price',
            'oil_use' => 'Oil Use',
            'oil_model' => 'Oil Model',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }

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