<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "template_location".
 *
 * @property integer $template_location_id
 * @property string $template_location_name
 * @property string $template_location_title
 * @property integer $width
 * @property integer $height
 * @property integer $sort
 * @property integer $is_slider
 * @property integer $is_banner
 *
 * @property Banner[] $banners
 * @property Slider[] $sliders
 */
class TemplateLocation extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'template_location';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['template_location_name', 'width', 'height', 'sort'], 'required'],
            [['width', 'height', 'sort', 'is_slider', 'is_banner'], 'integer'],
            [['template_location_name', 'template_location_title'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'template_location_id' => Yii::t('app', 'template_location_id'),
            'template_location_name' => Yii::t('app', 'template_location_name'),
            'template_location_title' => Yii::t('app', 'template_location_title'),
            'width' => Yii::t('app', 'width'),
            'height' => Yii::t('app', 'height'),
            'sort' => Yii::t('app', 'sort'),
            'is_slider' => Yii::t('app', 'is_slider'),
            'is_banner' => Yii::t('app', 'is_banner'),
        ];
    }

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

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