<?php

namespace common\models;

use Yii;

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

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['price'], 'number'],
            [['project_id', 'level_id'], 'integer'],
            [['created_at', 'updated_at'], 'safe'],
            [['level_id'], 'exist', 'skipOnError' => true, 'targetClass' => FixMetalLevel::className(), 'targetAttribute' => ['level_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',
            'level_id' => 'Level ID',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }

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