<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "fix_car_paint".
 *
 * @property integer $id
 * @property string $price
 * @property integer $project_id
 * @property integer $car_price_id
 * @property string $created_at
 * @property string $updated_at
 *
 * @property FixCarPrice $carPrice
 * @property FixCarProject $project
 */
class FixCarPaint extends \common\models\Base
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'fix_car_paint';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['price'], 'number'],
            [['project_id', 'car_price_id'], 'integer'],
            [['created_at', 'updated_at'], 'safe'],
            [['car_price_id'], 'exist', 'skipOnError' => true, 'targetClass' => FixCarPrice::className(), 'targetAttribute' => ['car_price_id' => 'id']],
            [['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => FixCarProject::className(), 'targetAttribute' => ['project_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'price' => 'Price',
            'project_id' => 'Project ID',
            'car_price_id' => 'Car Price ID',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }

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

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