<?php

namespace common\modules\triggers\models;

use Yii;

/**
 * This is the model class for table "trigger_param".
 *
 * @property integer $id
 * @property integer $condition_id
 * @property string $key
 * @property string $value
 *
 * @property TriggerCondition $condition
 */
class TriggerParam extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'trigger_param';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['condition_id'], 'required'],
            [['condition_id'], 'integer'],
            [['key', 'value'], 'string'],
            [['condition_id'], 'exist', 'skipOnError' => true, 'targetClass' => TriggerCondition::className(), 'targetAttribute' => ['condition_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'condition_id' => 'Condition ID',
            'key' => 'Key',
            'value' => 'Value',
        ];
    }

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