Guarantee.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class Guarantee extends Model
  5. {
  6. // 表名
  7. protected $name = 'shop_guarantee';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'status_text'
  17. ];
  18. protected static $config = [];
  19. protected static $tagCount = 0;
  20. protected static function init()
  21. {
  22. $config = get_addon_config('shop');
  23. self::$config = $config;
  24. }
  25. public function getStatusList()
  26. {
  27. return ['normal' => __('Normal'), 'hidden' => __('Hidden')];
  28. }
  29. public function getStatusTextAttr($value, $data)
  30. {
  31. $value = $value ?: ($data['status'] ?? '');
  32. $list = $this->getStatusList();
  33. return $list[$value] ?? '';
  34. }
  35. public function getImageAttr($value, $data)
  36. {
  37. $value = $value ? $value : "/assets/addons/shop/img/checked.png";
  38. return cdnurl($value, true);
  39. }
  40. }