| Current Path : /var/www/html/chatbot/backend/models/ |
| Current File : /var/www/html/chatbot/backend/models/Message.php |
<?php
namespace backend\models;
use backend\models\MessageGroup;
use backend\models\Staff;
use common\models\Dermaga;
use Yii;
/**
* This is the model class for table "message".
*
* @property integer $id
* @property string $box
* @property string $sender
* @property string $recipient
* @property string $title
* @property string $message
* @property string $date_sent
* @property string $time_sent
* @property integer $group
* @property integer $read
* @property string $pic
* @property string $pic_sys
* @property integer $status
* @property integer $outbox
* @property integer $individu
* @property integer $sendernm
* @property integer $holderone
*/
class Message extends Dermaga
{
const individual = 101;
const group_message = 102;
public $individu;
public $holderone;
public static function tableName()
{
return 'dmg_message';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['message'], 'string'],
[['title','individu','message','recipient'], 'required', 'on' => 'individual'],
[['title','individu','message','group'], 'required', 'on' => 'group_message'],
[['title','message'], 'required', 'on' => 'outbox'],
[['title','message'], 'required', 'on' => 'draft'],
[['recipient','created_by', 'updated_by','sender','status','date_sent', 'time_sent','created_att', 'updated_at'], 'safe'],
[['read', 'outbox'], 'integer'],
[[ 'title'], 'string', 'max' => 255],
[['pic', 'pic_sys'], 'string', 'max' => 100],
];
}
public function getGroupMessage() {
return $this->hasOne(MessageGroup::className(), ['id' => 'group'])->andWhere(['cat'=>'PMSTATUS']);
}
public function getStaffRecipient() {
return $this->hasOne(Staff::className(), ['id' => 'recipient']);
}
public function getStaffSender() {
return $this->hasOne(Staff::className(), ['id' => 'sender']);
}
public function attributeLabels()
{
return [
'id' => 'ID',
'sender' => yii::t('app',''),
'sendernm'=> yii::t('app','Sender'),
'recipient' => yii::t('app',''),
'holderone' => yii::t('app',' '),
'individu'=> yii::t('app','Individu'),
'title' => yii::t('app',''),
'message' => yii::t('app',''),
'date_sent' => yii::t('app','Tarikh Hantar'),
'time_sent' => yii::t('app','Waktu Dihantar'),
'group' => yii::t('app','Kumpulan'),
'read' => yii::t('app','Baca'),
'pic' => yii::t('app','Lampiran'),
'pic_sys' => yii::t('app','Pic Sys'),
'status' => yii::t('app','Status'),
'outbox' => yii::t('app','Kotak Keluar'),
];
}
}