Sku.php 919 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. /**
  5. * 模型
  6. */
  7. class Sku extends Model
  8. {
  9. // 表名
  10. protected $name = 'shop_goods_sku';
  11. // 开启自动写入时间戳字段
  12. protected $autoWriteTimestamp = 'int';
  13. // 定义时间戳字段名
  14. protected $createTime = 'createtime';
  15. protected $updateTime = 'updatetime';
  16. // 追加属性
  17. protected $append = [
  18. ];
  19. protected static $config = [];
  20. protected static $tagCount = 0;
  21. protected static function init()
  22. {
  23. $config = get_addon_config('shop');
  24. self::$config = $config;
  25. }
  26. public function getImageAttr($value, $data)
  27. {
  28. if (!$value) {
  29. return $value;
  30. }
  31. $value = $value ? $value : '';
  32. return cdnurl($value, true);
  33. }
  34. public function goods()
  35. {
  36. return $this->belongsTo("Goods", "goods_id", "id", [], 'LEFT');
  37. }
  38. }