<?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']);
    }
}
