<?php

namespace app\modules\hub\models\db;

use Yii;

/**
 * This is the model class for table "ist_session".
 *
 * @property int $id
 * @property int $hub_id
 * @property string $sid
 * @property string $status
 * @property string $start_datetime
 * @property string $end_datetime
 * @property string $created_on
 *
 * @property IstHub $hub
 * @property IstSessionPeers[] $istSessionPeers
 */
class IstSession extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'ist_session';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['hub_id', 'sid', 'status', 'start_datetime', 'created_on'], 'required'],
            [['hub_id'], 'integer'],
            [['status'], 'string'],
            [['start_datetime', 'end_datetime', 'created_on'], 'safe'],
            [['sid'], 'string', 'max' => 46],
            [['hub_id'], 'exist', 'skipOnError' => true, 'targetClass' => IstHub::className(), 'targetAttribute' => ['hub_id' => 'id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'hub_id' => 'Hub ID',
            'sid' => 'Sid',
            'status' => 'Status',
            'start_datetime' => 'Start Datetime',
            'end_datetime' => 'End Datetime',
            'created_on' => 'Created On',
        ];
    }

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

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