<?php

namespace nota\models;

use Yii;

/**
 * This is the model class for table "member".
 *
 * @property int $id
 * @property int|null $idKelas
 * @property int|null $idCluster
 * @property string $vNama
 * @property string $vHp
 * @property string $vImage
 * @property string $vFacebook
 * @property string $vIg
 * @property string $email
 * @property string $auth_key
 * @property string $password_hash
 * @property string|null $password_reset_token
 * @property string|null $eType
 * @property string|null $eDeleted
 * @property int $status
 * @property int $created_at
 * @property int $updated_at
 * @property string|null $verification_token
 */
class Usermember extends \yii\db\ActiveRecord
{
	public static function getDb() {
        return Yii::$app->get('dbnota'); 
    }
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'member';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['idKelas', 'status'], 'integer'],
            [['vNama',], 'required'],
            [['eType', 'eDeleted','eGender','vBio','dTgllhr','eAdmin','idCluster','vBlok'], 'string'],
            [['slug', 'vNIK', 'vHp', 'vImage', 'vFacebook', 'vIg', 'dTmpatlahir'], 'string', 'max' => 100],
            [['email',  'email2', 'password_hash', 'password_reset_token', 'verification_token'], 'string', 'max' => 255],
            [['auth_key'], 'string', 'max' => 32],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'idKelas' => 'Kelas',
            'idCluster' => 'Nama Perumahan / Komplek / Gang / Kostan',
            'vNama' => 'Nama',
            'eAdmin' => 'eAdmin',
            'slug' => 'Slug',
            'vNIK' => 'Nomor KTP',
            'vNIS' => 'Nomor Induk Siswa',
            'vHp' => 'No. Hp',
            'vImage' => 'Foto Profil',
            'vFacebook' => 'Facebook',
            'vIg' => 'Instagram',
            'dTmpatlahir' => 'Tempat lahir',
            'dTgllhr' => 'Tgl. lahir',
            'email' => 'Email',
            'email2' => 'Email Siswa',
            'auth_key' => 'Auth Key',
            'password_hash' => 'Password Hash',
            'password_reset_token' => 'Password Reset Token',
            'eType' => 'Type',
            'eGender' => 'Jenis kelamin',
            'vBio' => 'Biografi / Tentang saya',
            'eDeleted' => 'Deleted',
            'login_time' => 'Login Time',
            'status' => 'Status',
            'created_at' => 'Created',
            'updated_at' => 'Updated',
            'verification_token' => 'Verification Token',
            'vBlok' => 'Blok / No. Rumah',
        ];
    }
	
	public function getKelas()
    {
        return $this->hasOne(Kelas::className(), ['iId' => 'idKelas']);
    }

    public function getDevice()
    {
        return $this->hasOne(UserDevice::className(), ['iId' => 'iUserId']);
    }
}
