Logs.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace app\common\model\account;
  3. use think\Model;
  4. class Logs extends Model
  5. {
  6. // 表名
  7. protected $name = 'account_logs';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'integer';
  10. protected $dateFormat = 'Y-m-d H:i:s';
  11. // 定义时间戳字段名
  12. protected $createTime = 'createtime';
  13. protected $updateTime = 'updatetime';
  14. protected $deleteTime = false;
  15. // 追加属性
  16. protected $append = [
  17. 'type_text',
  18. 'credit_type_text',
  19. 'inc_or_exp_text'
  20. ];
  21. public function getTypeList()
  22. {
  23. return ['1' => __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3'), '4' => __('Type 4'), '5' => __('Type 5'), '6' => __('Type 6'), '7' => __('Type 7'), '9' => __('Type 9')];
  24. }
  25. public function getCreditTypeList()
  26. {
  27. return ['1' => __('Credit_type 1'), '2' => __('Credit_type 2'), '3' => __('Credit_type 3'), '4' => __('Credit_type 4'), '5' => __('Credit_type 5'), '9' => __('Credit_type 9')];
  28. }
  29. public function getIncOrExpList()
  30. {
  31. return ['0' => __('Inc_or_exp 0'), '1' => __('Inc_or_exp 1'), '2' => __('Inc_or_exp 2')];
  32. }
  33. public function getTypeTextAttr($value, $data)
  34. {
  35. $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
  36. $list = $this->getTypeList();
  37. return isset($list[$value]) ? $list[$value] : '';
  38. }
  39. public function getCreditTypeTextAttr($value, $data)
  40. {
  41. $value = $value ? $value : (isset($data['credit_type']) ? $data['credit_type'] : '');
  42. $list = $this->getCreditTypeList();
  43. return isset($list[$value]) ? $list[$value] : '';
  44. }
  45. public function getIncOrExpTextAttr($value, $data)
  46. {
  47. $value = $value ? $value : (isset($data['inc_or_exp']) ? $data['inc_or_exp'] : '');
  48. $list = $this->getIncOrExpList();
  49. return isset($list[$value]) ? $list[$value] : '';
  50. }
  51. }