<?php

namespace frontend\models;

use Yii;

/**
 * This is the model class for table "options".
 *
 * @property integer $option_id
 * @property string $option_key
 * @property integer $option_parent
 * @property integer $option_translatable
 * @property string $option_format
 *
 * @property OptionValues[] $optionValues
 * @property Options $optionParent
 * @property Options[] $options
 */
class Options extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'options';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['option_key'], 'required'],
            [['option_parent', 'option_translatable'], 'integer'],
            [['option_key', 'option_format'], 'string', 'max' => 200]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'option_id' => Yii::t('app', 'Option ID'),
            'option_key' => Yii::t('app', 'Option Key'),
            'option_parent' => Yii::t('app', 'Option Parent'),
            'option_translatable' => Yii::t('app', 'Option Translatable'),
            'option_format' => Yii::t('app', 'Option Format'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getOptionValues()
    {
        return $this->hasMany(OptionValues::className(), ['option_id' => 'option_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getOptionParent()
    {
        return $this->hasOne(Options::className(), ['option_id' => 'option_parent']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getOptions()
    {
        return $this->hasMany(Options::className(), ['option_parent' => 'option_id']);
    }
}
