php - 如何更改要阅读的消息状态
问题描述
在显示所有聊天消息时,我尝试更改消息的状态(已读或未读)。
实体
class Message
{
/**
* @ORM\Column(type="text",nullable=true)
* @var string|null
*/
public ?string $text;
/**
* @ORM\Column(type="guid",nullable=true)
* @var string|null
*/
public ?string $imageId;
/**
* @ORM\Column(type="datetime_immutable")
* @var DateTimeImmutable
*/
public DateTimeImmutable $createdAt;
/**
* @ORM\Column(type="boolean")
* @var bool
*/
public bool $received;
}
控制器 AllMessage
$message = $this->supportMessageRepository->findAllByUserId($customerId);
$items = array_map([$this->supportMessageMapper, 'map'], $message);
思路: 实现思路:当窗口打开或用户开始输入时,获取前面的标志为true | false 并且如果标志为 true,则更改消息的状态
问题: 但我不明白如何在收到列表时更改消息的状态(新的、尚未阅读的)。
问题: 如果用户每次调用一个方法来获取消息列表,调用时间是节省的,如果比上一次长,就在entity中创建一个函数来改变状态。问题是,这会起作用吗,还是我能以这种方式仅更改一条消息的状态?
解决方案
推荐阅读
- regex - 仅当存在另一个元素时如何将元素放入正则表达式
- c# - join 子句中的表达式之一的类型不正确。类型推断失败
- python - 用于分隔 Excel 工作表的多个数据框列表
- algorithm - 有没有一种有效的方法来计算比特流中 1 的密度?
- sql - 将数据从 SQL 输出导出到 csv 时出错
- javascript - 是否有任何 JS 智能 json 模式验证器,比如 Joi,但有动态自定义错误?
- ios - FUIEmailAuth 未声明
- sql - 确定开始时间和结束时间之间的每个小时
- c# - 比较 2 个列表的 UnorderedEquals 方法在布尔值上失败
- linkedin - 我如何将我的域列入白名单以使用linkedin启用自动填充