2 changed files with 115 additions and 3 deletions
@ -0,0 +1,49 @@ |
|||
<?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]); |
|||
} |
|||
|
|||
} |
|||
Loading…
Reference in new issue