Message.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace app\admin\model\system;
  3. use think\Model;
  4. class Message extends Model
  5. {
  6. // 表名
  7. protected $name = 'system_message';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'integer';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'identity_type_text'
  17. ];
  18. public function getIdentityTypeList()
  19. {
  20. return ['agent' => __('Agent'), 'store' => __('Store'), 'massager' => __('Massager'), 'user' => __('User')];
  21. }
  22. public function getIdentityTypeTextAttr($value, $data)
  23. {
  24. $value = $value ? $value : (isset($data['identity_type']) ? $data['identity_type'] : '');
  25. $list = $this->getIdentityTypeList();
  26. return isset($list[$value]) ? $list[$value] : '';
  27. }
  28. public function user()
  29. {
  30. return $this->belongsTo('app\admin\model\User', 'to_user_id', 'id', [], 'LEFT')->setEagerlyType(0);
  31. }
  32. public function massager()
  33. {
  34. return $this->belongsTo('app\admin\model\Massager', 'to_massager_id', 'id', [], 'LEFT')->setEagerlyType(0);
  35. }
  36. }