<?php

namespace common\models;

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

/**
 * This is the model class for table "event_equipment_type_assignment".
 *
 * @property integer $id
 * @property integer $id_event
 * @property integer $id_event_equipment_type
 * @property integer $count
 * @property string $created_at
 * @property string $updated_at
 *
 * @property Event $idEvent
 * @property EventEquipmentType $idEventEquipmentType
 */
class EventEquipmentTypeAssignment extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'event_equipment_type_assignment';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id_event', 'id_event_equipment_type', 'count'], 'integer'],
            [['created_at', 'updated_at'], 'required'],
            [['created_at', 'updated_at'], 'safe']
        ];
    }

    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', 'ID'),
            'id_event' => Yii::t('common/event', 'Id Event'),
            'id_event_equipment_type' => Yii::t('common/event', 'Id Event Equipment Type'),
            'count' => Yii::t('common/event', 'Count'),
            'created_at' => Yii::t('common/event', 'Created At'),
            'updated_at' => Yii::t('common/event', 'Updated At'),
        ];
    }

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

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