<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "fix_item_record".
 *
 * @property integer $id
 * @property string $name
 * @property integer $group_id
 * @property integer $item_id
 * @property integer $fix_id
 * @property integer $brand_id
 * @property integer $series_id
 * @property integer $displacement_id
 * @property string $car_year
 * @property integer $number
 * @property string $price
 * @property integer $get_user
 * @property string $get_at
 * @property integer $status
 * @property integer $is_del
 * @property string $created_at
 * @property string $updated_at
 *
 * @property BrandT $brand
 * @property DisplacementT $displacement
 * @property FixCarT $fix
 * @property UserT $getUser
 * @property FixCarGroup $group
 * @property FixCarItemT $item
 * @property SeriesT $series
 */
class FixItemRecord extends \common\models\Base
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'fix_item_record';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['group_id', 'item_id', 'fix_id', 'brand_id', 'series_id', 'displacement_id', 'number', 'get_user', 'status', 'is_del'], 'integer'],
            [['price'], 'number'],
            [['get_at', 'created_at', 'updated_at'], 'safe'],
            [['name'], 'string', 'max' => 100],
            [['car_year'], 'string', 'max' => 50],
            [['brand_id'], 'exist', 'skipOnError' => true, 'targetClass' => BrandT::className(), 'targetAttribute' => ['brand_id' => 'id']],
            [['displacement_id'], 'exist', 'skipOnError' => true, 'targetClass' => DisplacementT::className(), 'targetAttribute' => ['displacement_id' => 'id']],
            [['fix_id'], 'exist', 'skipOnError' => true, 'targetClass' => FixCarT::className(), 'targetAttribute' => ['fix_id' => 'id']],
            [['get_user'], 'exist', 'skipOnError' => true, 'targetClass' => UserT::className(), 'targetAttribute' => ['get_user' => 'id']],
            [['group_id'], 'exist', 'skipOnError' => true, 'targetClass' => FixCarGroup::className(), 'targetAttribute' => ['group_id' => 'id']],
            [['item_id'], 'exist', 'skipOnError' => true, 'targetClass' => FixCarItemT::className(), 'targetAttribute' => ['item_id' => 'id']],
            [['series_id'], 'exist', 'skipOnError' => true, 'targetClass' => SeriesT::className(), 'targetAttribute' => ['series_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'group_id' => 'Group ID',
            'item_id' => 'Item ID',
            'fix_id' => 'Fix ID',
            'brand_id' => 'Brand ID',
            'series_id' => 'Series ID',
            'displacement_id' => 'Displacement ID',
            'car_year' => 'Car Year',
            'number' => 'Number',
            'price' => 'Price',
            'get_user' => 'Get User',
            'get_at' => 'Get At',
            'status' => 'Status',
            'is_del' => 'Is Del',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }

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

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

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

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

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

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

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