<?php

namespace common\models;

use Yii;
use yii\behaviors\TimestampBehavior;
use yii\helpers\ArrayHelper;

/**
 * This is the model class for table "event_equipment_type".
 *
 * @property integer $id
 * @property string $name
 * @property string $created_at
 * @property string $updated_at
 *
 * @property EventEquipmentTypeAssignment[] $eventEquipmentTypeAssignments
 * @property EventRegistrationEquipmentTypeAssignment[] $eventRegistrationEquipmentTypeAssignments
 */
class EventEquipmentType extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'event_equipment_type';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name'], 'required'],
            [['name'], 'string', 'max' => 255]
        ];
    }

    public function behaviors()
    {
        return ArrayHelper::merge(  [
            [
                'class' => TimestampBehavior::className(),
                'value' => function(){ return date('Y-m-d H:i:s' ); }
            ]
        ],
            parent::behaviors());
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('common/event-equipment-type', 'ID'),
            'name' => Yii::t('common/event-equipment-type', 'Name'),
            'created_at' => Yii::t('common/event-equipment-type', 'Created At'),
            'updated_at' => Yii::t('common/event-equipment-type', 'Updated At'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEventEquipmentTypeAssignments()
    {
        return $this->hasMany(EventEquipmentTypeAssignment::className(), ['id_event_equipment_type' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEventRegistrationEquipmentTypeAssignments()
    {
        return $this->hasMany(EventRegistrationEquipmentTypeAssignment::className(), ['id_event_equipment_type' => 'id']);
    }
}
