增加后台消息通知管理
This commit is contained in:
@@ -32,15 +32,16 @@ class MessageNotifications extends Model
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
public $timestamps = false;
|
||||
|
||||
// const UPDATED_AT = false;
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
// protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'msg_no', 'sender_id', 'sender_type', 'recipient', 'title', 'content', 'scene', 'created_at'];
|
||||
protected $fillable = ['id', 'msg_no', 'sender_id', 'sender_type', 'recipient', 'title', 'content', 'scene', 'push_method', 'created_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
@@ -54,4 +55,39 @@ class MessageNotifications extends Model
|
||||
];
|
||||
const SCENE0 = 0;
|
||||
const SCENE1 = 1;
|
||||
|
||||
// 推送方式
|
||||
const PUSH_METHOD = [
|
||||
self::PUSH_METHOD0 => '系统推送',
|
||||
self::PUSH_METHOD1 => '手动推送'
|
||||
];
|
||||
const PUSH_METHOD0 = 0;
|
||||
const PUSH_METHOD1 = 1;
|
||||
|
||||
|
||||
/**
|
||||
* 关联用户消息状态 (一对多)
|
||||
*/
|
||||
public function userStatuses()
|
||||
{
|
||||
return $this->hasMany(MessageUserStatus::class, 'msg_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已读用户状态
|
||||
*/
|
||||
public function readUsers()
|
||||
{
|
||||
return $this->hasMany(MessageUserStatus::class, 'msg_id', 'id')
|
||||
->where('status', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取未读用户状态
|
||||
*/
|
||||
public function unreadUsers()
|
||||
{
|
||||
return $this->hasMany(MessageUserStatus::class, 'msg_id', 'id')
|
||||
->where('status', 0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user