KefuToolbar.php 1.3 KB

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