Help.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace app\admin\model\help;
  3. use think\Model;
  4. use traits\model\SoftDelete;
  5. class Help extends Model
  6. {
  7. use SoftDelete;
  8. // 表名
  9. protected $name = 'help';
  10. // 自动写入时间戳字段
  11. protected $autoWriteTimestamp = 'int';
  12. // 定义时间戳字段名
  13. protected $createTime = 'createtime';
  14. protected $updateTime = 'updatetime';
  15. protected $deleteTime = 'deletetime';
  16. // 追加属性
  17. protected $append = [
  18. 'isrec_text',
  19. 'status_text'
  20. ];
  21. public function getIsrecList()
  22. {
  23. return ['0' => __('Isrec 0'), '1' => __('Isrec 1')];
  24. }
  25. public function getStatusList()
  26. {
  27. return ['-1' => __('Status -1'), '0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3'), '4' => __('Status 4')];
  28. }
  29. public function getIsrecTextAttr($value, $data)
  30. {
  31. $value = $value ? $value : (isset($data['isrec']) ? $data['isrec'] : '');
  32. $list = $this->getIsrecList();
  33. return isset($list[$value]) ? $list[$value] : '';
  34. }
  35. public function getStatusTextAttr($value, $data)
  36. {
  37. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  38. $list = $this->getStatusList();
  39. return isset($list[$value]) ? $list[$value] : '';
  40. }
  41. }