2026-05-29 19:54:56 +08:00

64 lines
1.4 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Created by PhpStorm.
* User: zn
* Date: 2017/6/15
* Time: 10:02
*/
namespace common\models;
use common\utils\EnumUtil;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
/**
* Class Message
* @package common\models
* @property int $id id
* @property int $be_user_id 接收消息的用户ID
* @property int $type 消息操作类型
* @property int $data 内容json格式
* @property int $readed 是否已读
* @property int $created_at
* @property int $updated_at
*/
class Message extends ActiveRecord
{
public function behaviors()
{
return [
TimestampBehavior::className(),
];
}
public function rules()
{
return [
['be_user_id', 'exist', 'targetClass' => '\common\models\User', 'targetAttribute' => 'id'],
['type', 'default', 'value' => EnumUtil::MESSAGE_CONFIRM_BE_USER_DEAL],
['type', 'in', 'range' => EnumUtil::MESSAGE_LIST],
['readed', 'default', 'value' => EnumUtil::NOT_READ],
['readed', 'in', 'range' => EnumUtil::READ_LIST],
];
}
public static function findByID($id)
{
return self::findOne(['id' => $id]);
}
public function genClientData()
{
return [
'id' => $this->id,
'be_user_id' => $this->be_user_id,
'type' => $this->type,
'data' => $this->data,
'readed' => $this->readed,
];
}
}