增加后台消息通知管理

This commit is contained in:
mzl
2025-08-21 15:47:05 +08:00
parent 58dc6729d9
commit c1de258ce2
8 changed files with 197 additions and 18 deletions
+39 -3
View File
@@ -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);
}
}