<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "store_log".
 *
 * @property integer $id
 * @property string $op_man
 * @property string $op_time
 * @property integer $type
 * @property integer $brand_id
 * @property integer $series_id
 * @property integer $displacement_id
 * @property integer $year_id
 * @property string $get_man
 * @property integer $number
 * @property string $name
 * @property string $created_at
 * @property string $updated_at
 *
 * @property BrandT $brand
 * @property DisplacementT $displacement
 * @property SeriesT $series
 * @property YearT $year
 */
class StoreLog extends \common\models\Base
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'store_log';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['op_time', 'created_at', 'updated_at'], 'safe'],
            [['type', 'brand_id', 'series_id', 'displacement_id', 'year_id', 'number'], 'integer'],
            [['op_man', 'get_man'], 'string', 'max' => 50],
            [['name'], 'string', 'max' => 100],
            [['brand_id'], 'exist', 'skipOnError' => true, 'targetClass' => BrandT::className(), 'targetAttribute' => ['brand_id' => 'id']],
            [['displacement_id'], 'exist', 'skipOnError' => true, 'targetClass' => DisplacementT::className(), 'targetAttribute' => ['displacement_id' => 'id']],
            [['series_id'], 'exist', 'skipOnError' => true, 'targetClass' => SeriesT::className(), 'targetAttribute' => ['series_id' => 'id']],
            [['year_id'], 'exist', 'skipOnError' => true, 'targetClass' => YearT::className(), 'targetAttribute' => ['year_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'op_man' => 'Op Man',
            'op_time' => 'Op Time',
            'type' => 'Type',
            'brand_id' => 'Brand ID',
            'series_id' => 'Series ID',
            'displacement_id' => 'Displacement ID',
            'year_id' => 'Year ID',
            'get_man' => 'Get Man',
            'number' => 'Number',
            'name' => 'Name',
            '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 getSeries()
    {
        return $this->hasOne(SeriesT::className(), ['id' => 'series_id']);
    }

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