<?php

namespace app\modules\hub\models\db;

use Yii;

/**
 * This is the model class for table "ist_hub".
 *
 * @property int $id
 * @property int $type_id
 * @property string $domain
 * @property string $created_on
 *
 * @property IstHubType $type
 * @property IstPeers[] $istPeers
 * @property IstSession[] $istSessions
 */
class IstHub extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'ist_hub';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['type_id', 'domain', 'created_on'], 'required'],
            [['type_id'], 'integer'],
            [['created_on'], 'safe'],
            [['domain'], 'string', 'max' => 256],
            [['type_id'], 'exist', 'skipOnError' => true, 'targetClass' => IstHubType::className(), 'targetAttribute' => ['type_id' => 'id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'type_id' => 'Type ID',
            'domain' => 'Domain',
            'created_on' => 'Created On',
        ];
    }

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

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getIstPeers()
    {
        return $this->hasMany(IstPeers::className(), ['hub_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getIstSessions()
    {
        return $this->hasMany(IstSession::className(), ['hub_id' => 'id']);
    }
}
