123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- /**
- * MessageModel.php UTF-8
- * huosdk_mobi
- *
- * @date : 2017/11/24 18:24
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : wuyonghong <wyh@huosdk.com>
- * @version : HUOSDK 8.0
- */
- namespace huo\model\message;
- use huo\model\common\CommonModel;
- use huo\model\game\GameModel;
- use huo\model\member\MemberModel;
- class MessageModel extends CommonModel {
- protected $name = 'message';
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = true;
- public function memMsg() {
- return $this->hasOne(MemMessageModel::className(), 'message_id', 'id');
- }
- public function game() {
- return $this->belongsTo(GameModel::className(), 'app_id', 'id');
- }
- public function mem() {
- return $this->belongsTo(MemberModel::className(), 'mem_id', 'id');
- }
- /**
- * 基础查询
- *
- * @param $query
- */
- protected function base($query) {
- $query->where('delete_time', 0)
- ->where('is_delete', 2);
- }
- /**
- * post_content 自动转化
- *
- * @param $value
- *
- * @return string
- */
- public function setMessageAttr($value) {
- return htmlspecialchars(cmf_replace_content_file_url(htmlspecialchars_decode($value), true));
- }
- /**
- * content 自动转化
- *
- * @param $value
- *
- * @return string
- */
- public function getContentAttr($value) {
- return cmf_replace_content_file_url(htmlspecialchars_decode($value));
- }
- /**
- * content 自动转化
- *
- * @param $value
- *
- * @return string
- */
- public function setContentAttr($value) {
- return htmlspecialchars(cmf_replace_content_file_url(htmlspecialchars_decode($value), true));
- }
- /**
- * 添加评论
- *
- * @param $data
- *
- * @return bool|mixed
- */
- public static function addMessage($data) {
- if (!$data) {
- return false;
- }
- if ($obj = self::create($data)) {
- return $obj->id;
- } else {
- return false;
- }
- }
- public static function updateMessage($data, $id) {
- $_map['id'] = $id;
- $_data = $data;
- $_rs = self::update($_data, $_map, true);
- if (false == $_rs) {
- return false;
- } else {
- return true;
- }
- }
- }
|