You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.0 KiB
49 lines
1.0 KiB
<?php
|
|
|
|
namespace app\enterprise\model;
|
|
|
|
use think\Model;
|
|
|
|
class PostsNotice extends Model
|
|
{
|
|
|
|
/**
|
|
* 添加 或 删除 消息
|
|
* @param $posts_id // 帖子id
|
|
* @param $relevance_id // 关联id
|
|
* @param $user_id // 通知用户id
|
|
* @param $type // 通知类型 1点赞 2评论
|
|
* @return void
|
|
*/
|
|
public static function optionNotice(
|
|
int $posts_id,
|
|
int $relevance_id,
|
|
int $user_id,
|
|
int $type = 1,
|
|
string $option = 'add'
|
|
) {
|
|
$data = [
|
|
'posts_id' => $posts_id,
|
|
'relevance_id' => $relevance_id,
|
|
'user_id' => $user_id,
|
|
'type' => $type
|
|
];
|
|
if ($option == 'add') {
|
|
self::create($data);
|
|
} elseif ($option == 'del') {
|
|
self::where($data)->delete();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 标记已读
|
|
* @param $id
|
|
* @return void
|
|
*/
|
|
public static function read($id)
|
|
{
|
|
$data = ['is_read' => 1];
|
|
self::update($data, ['id' => $id]);
|
|
}
|
|
|
|
}
|