<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "t_kandidat".
 *
 * @property int $id_kandidat
 * @property string $nama_kandidat
 * @property int $id_voting
 *
 * @property MVoting $voting
 */
class TKandidat extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 't_kandidat';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['nama_kandidat', 'id_voting'], 'required'],
            [['id_voting'], 'integer'],
            [['nama_kandidat'], 'string', 'max' => 500],
            [['id_voting'], 'exist', 'skipOnError' => true, 'targetClass' => MVoting::className(), 'targetAttribute' => ['id_voting' => 'id_voting']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id_kandidat' => 'Id Kandidat',
            'nama_kandidat' => 'Nama Kandidat',
            'id_voting' => 'Id Voting',
        ];
    }

    /**
     * Gets query for [[Voting]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getVoting()
    {
        return $this->hasOne(MVoting::className(), ['id_voting' => 'id_voting']);
    }
}
