<?php

namespace common\models;

use Yii;

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

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

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'series_id' => 'Series ID',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }

    public function getSeries()
    {
        return $this->hasOne(Series2T::className(),['id'=>'series_id']);
    }

    public function getYears()
    {
        return $this->hasMany(YearT::className(),['displacement_id'=>'id']);
    }
}
