1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace app\common\model;
- use think\Model;
- class Messages extends Model
- {
-
-
- // 表名
- protected $name = 'messages';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'integer';
- protected $dateFormat = 'Y-m-d H:i:s';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'message_type_text',
- 'createtime_text'
- ];
- protected $type = [
- 'extra_json' => 'array',
- ];
-
-
- public function getMessageTypeList()
- {
- return ['0' => __('Message_type 0'), '1' => __('Message_type 1')];
- }
- public function getMessageTypeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['message_type']) ? $data['message_type'] : '');
- $list = $this->getMessageTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getCreatetimeTextAttr($value, $data)
- {
- return date('m/d|H:i', $data['createtime'] ?? 0);
- }
- }
|