<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "seo_dynamic".
 *
 * @property integer $seo_dynamic_id
 * @property integer $seo_category_id
 * @property string $name
 * @property string $action
 * @property string $fields
 * @property string $title
 * @property string $h1
 * @property string $description
 * @property string $seo_text
 * @property integer $status
 * @property string $param
 * @property string $key
 *
 * @property SeoCategory $seoCategory
 */
class SeoDynamic extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'seo_dynamic';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['seo_category_id', 'status'], 'integer'],
            [['seo_text'], 'string'],
            [['name', 'action'], 'string', 'max' => 200],
            [['fields', 'title', 'meta', 'h1', 'description', 'param', 'key'], 'string', 'max' => 255],
            [['seo_category_id'], 'exist', 'skipOnError' => true, 'targetClass' => SeoCategory::className(), 'targetAttribute' => ['seo_category_id' => 'seo_category_id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'seo_dynamic_id' => Yii::t('app', 'seo_dynamic_id'),
            'seo_category_id' => Yii::t('app', 'seo_category_id'),
            'name' => Yii::t('app', 'name'),
            'action' => Yii::t('app', 'action'),
            'fields' => Yii::t('app', 'fields'),
            'title' => Yii::t('app', 'title'),
            'meta' => Yii::t('app', 'meta'),
            'h1' => Yii::t('app', 'h1'),
            'description' => Yii::t('app', 'description'),
            'seo_text' => Yii::t('app', 'seo_text'),
            'status' => Yii::t('app', 'status'),
            'param' => Yii::t('app', 'param'),
            'key' => Yii::t('app', 'key'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getSeoCategory()
    {
        return $this->hasOne(SeoCategory::className(), ['seo_category_id' => 'seo_category_id']);
    }
}
