Your IP : 216.73.216.124


Current Path : /var/www/html/chatbot/backend/models/
Upload File :
Current File : /var/www/html/chatbot/backend/models/Memo.php

<?php

namespace backend\models;

use Yii;
use backend\models\User;
use backend\models\Staff;
use common\models\Dermaga;
/**
 * This is the model class for table "memo".
 *
 * @property integer $id
 * @property string $memo_cat
 * @property string $memo_ty
 * @property string $memo_to
 * @property string $memo_from
 * @property string $msg
 * @property string $memo_dt
 * @property string $status
 * @property string $param
 * @property string $created_by
 * @property string $created_at
 * @property string $updated_by
 * @property string $updated_at
 */
class Memo extends Dermaga {

    /**
     * @inheritdoc
     */
    public static function tableName() {
        return 'dmg_memo';
    }

    /**
     * @inheritdoc
     */
    public function rules() {
        return [
            [['msg'], 'required'],
            [['msg'], 'string'],
            [['memo_to','memo_from','memo_dt', 'created_at', 'updated_at'], 'safe'],
            [['memo_cat'], 'string', 'max' => 3],
            [['param'], 'string', 'max' => 25],
            [['created_by', 'updated_by'], 'string', 'max' => 50],
            [['status'], 'string', 'max' => 1],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'memo_cat' =>  yii::t('app','Memo Cat'),
            'memo_to' =>  yii::t('app','Memo To'),
            'memo_from' =>  yii::t('app','Sender'),
            'msg' =>  yii::t('app','Message'),
            'memo_dt' =>  yii::t('app','Date'),
            'status' =>  yii::t('app','Status'),
            'param' =>  yii::t('app','Param'),
            'created_by' =>  yii::t('app','Created By'),
            'created_at' =>  yii::t('app','Created At'),
            'updated_by' =>  yii::t('app','Updated By'),
            'updated_at' =>  yii::t('app','Updated At'),
        ];
    }

    public function getFromstaff() {//raj add 20160811
        return $this->hasOne(Staff::className(), ['id' => 'memo_from']);
    }
    
    public function getTostaff() {//raj add 20160811
        return $this->hasOne(Staff::className(), ['id' => 'memo_to']);
    }
    
    public function myNewMemo(){
        $myMemo = $this->countByAttributes(array('memo_to'=>Yii::$app->user->identity->staff->id,'status'=>'N'));
        return $myMemo;
    }
//    public function getUser() {
//        return $this->hasOne(User::className(), ['id' => 'memo_from']);
//    }

}