Your IP : 216.73.216.124


Current Path : /var/www/html/ebook/backend/models/
Upload File :
Current File : /var/www/html/ebook/backend/models/UserDetail.php

<?php

namespace backend\models;

use Yii;
use backend\models\Staff;
use backend\models\StaffDetail;
use backend\models\User;
/**
 * This is the model class for table "user".
 *
 * @property integer $id
 * @property string $username
 * @property string $auth_key
 * @property string $password_hash
 * @property string $password_reset_token
 * @property string $email
 * @property string $last_login
 * @property string $last_login_attempts
 * @property string $login_attempts
 * @property integer $status
 * @property integer $is_admin
 * @property integer $created_at
 * @property integer $updated_at
 */
class User extends \yii\db\ActiveRecord 
{
    /**
     * @inheritdoc
     */
    public static function tableName() {
        return 'dmg_user';
    }

//    public $staff_name;
//    public $company_email;
//    public $confirmPassword;
//    public $roleCode;
//    public $sender;

    /**
     * @inheritdoc
     */

    public function rules()
    {
        return [
            [['email','username','staff_name'], 'required', 'on' => 'manageUser'],              
            [['last_login', 'last_login_attempts', 'login_attempts', 'status', 'is_admin', 'created_at', 'updated_at'], 'integer'],
            [['username', 'password_hash', 'confirmPassword', 'password_reset_token', 'email'], 'string', 'max' => 255],
            [['auth_key'], 'string', 'max' => 32],
//            [['staff_name'], 'string', 'max' => 100],
            [['username'], 'unique'],
            [['email'], 'email'],
            [['password_reset_token'], 'unique'],
//            [['confirmPassword'], 'compare', 'compareAttribute' => 'password_hash'],
        ]; 
    }

    public function getStaff()
    {
        return $this->hasOne(Staff::className(), ['userid' => 'id']);
    }
    
    public function getUserName() {
        return $this->username;
    }
    
    public function getSender()
    {
        return $this->hasOne(Message::className(), ['userid' => 'sender']);
    }
    
    public function attributeLabels() 
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'username' => Yii::t('app', 'Nama Pengguna'),
            'auth_key' => Yii::t('app', 'Auth Key'),
            'password_hash' => Yii::t('app', 'Kata Laluan'),
            'password_reset_token' => Yii::t('app', 'Password Reset Token'),
            'email' => Yii::t('app', 'Emel'),
            'last_login' => Yii::t('app', 'Log Masuk Kali Terakhir'),
            'last_login_attempts' => Yii::t('app', 'Last Login Attempts'),
            'login_attempts' => Yii::t('app', 'Login Attempts'),
            'status' => Yii::t('app', 'Status'),
            'is_admin' => Yii::t('app', 'Is Admin'),
            'created_at' => Yii::t('app', 'Created At'),
            'updated_at' => Yii::t('app', 'Updated At'),
            'name' => Yii::t('app', 'Nama Pekerja'),
            'location' => Yii::t('app', 'Lokasi'),
            'job_title' => Yii::t('app', 'Jawatan'),
            'confirmPassword' => Yii::t('app', 'Ulang Kata Laluan'),
        ];
    }
}