ThinkPHP6获取器没有触发
2022-11-24 11:10:29
204
{{single.collect_count}}

thinkphp6 获取器不触发

文档介绍的触发条件

  • 模型的数据对象取值操作($model->field_name)
  • 模型的序列化输出操作($model->toArray()及toJson())
  • 显式调用getAttr方法($this->getAttr(‘field_name’))

数组输出的字段值会经过获取器的处理,
如果不在数据表字段列表中的字段属性需要输出,必须使用append方法附加属性

// 数据表中存在的字段$result->toArray();// 不存在的字段使用append追加的方式获取$result->append(['status_text'])->toArray();

参考
https://www.kancloud.cn/manual/think-orm/1258057
thinkphp6 触发获取器

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}