<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "series2_t".
 *
 * @property integer $id
 * @property string $name
 * @property integer $factory_id
 * @property integer $brand_id
 * @property string $code
 * @property string $created_at
 * @property string $updated_at
 */
class Series2T extends \common\models\Base
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'series2_t';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name', 'factory_id', 'brand_id'], 'required'],
            [['factory_id', 'brand_id'], 'integer'],
            [['created_at', 'updated_at'], 'safe'],
            [['name'], 'string', 'max' => 100],
            [['code'], 'string', 'max' => 50],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'factory_id' => 'Factory ID',
            'brand_id' => 'Brand ID',
            'code' => 'Code',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }

    public function getBrand()
    {
        return $this->hasOne(Brand2T::className(),['id'=>'brand_id']);
    }

    public function getFactory()
    {
        return $this->hasOne(FactoryT::className(),['id'=>'factory_id']);
    }
}
