<?php namespace app\mobile\model; use think\Model; class News extends Model { // 表名 protected $name = 'mobile_news'; // 开启自动写入时间戳字段 protected $autoWriteTimestamp = 'int'; // 定义时间戳字段名 protected $createTime = 'createtime'; protected $updateTime = 'updatetime'; // 追加属性 protected $append = ['read_num']; public function getCoverAttr($value){ return !empty($value) ? cdnurl($value,true) : ''; } public function getReadNumAttr($value,$data){ return $data['read_num_virtual'] + $data['read_num_real']; } public function getCreatetimeAttr($value){ return date('Y.m.d',$value); } }