KeFuRecord.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class KeFuRecord extends Model
  5. {
  6. // 表名
  7. protected $name = 'kefu_record';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = false;
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'sender_identity_text',
  17. 'message_type_text',
  18. 'status_text'
  19. ];
  20. public function getSenderIdentityTextAttr($value, $data)
  21. {
  22. $value = $value ? $value : (isset($data['sender_identity']) ? $data['sender_identity'] : '');
  23. $list = $this->getSenderIdentityList();
  24. return isset($list[$value]) ? $list[$value] : '';
  25. }
  26. public function getSenderIdentityList()
  27. {
  28. return ['0' => __('Sender_identity 0'), '1' => __('Sender_identity 1')];
  29. }
  30. public function getMessageTypeTextAttr($value, $data)
  31. {
  32. $value = $value ? $value : (isset($data['message_type']) ? $data['message_type'] : '');
  33. $list = $this->getMessageTypeList();
  34. return isset($list[$value]) ? $list[$value] : '';
  35. }
  36. public function getMessageTypeList()
  37. {
  38. return [
  39. '0' => __('Message_type 0'),
  40. '1' => __('Message_type 1'),
  41. '2' => __('Message_type 2'),
  42. '3' => __('Message_type 3'),
  43. '4' => __('Message_type 4'),
  44. '5' => __('Message_type 5')
  45. ];
  46. }
  47. public function getStatusTextAttr($value, $data)
  48. {
  49. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  50. $list = $this->getStatusList();
  51. return isset($list[$value]) ? $list[$value] : '';
  52. }
  53. public function getStatusList()
  54. {
  55. return ['0' => __('Status 0'), '1' => __('Status 1')];
  56. }
  57. }