Goods.php 923 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace app\admin\model\shopro\commission;
  3. use think\Model;
  4. class Goods extends Model
  5. {
  6. // 表名
  7. protected $name = 'shopro_commission_goods';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = false;
  10. // 追加属性
  11. protected $append = [
  12. ];
  13. public function getCommissionRulesAttr($value, $data)
  14. {
  15. //默认规则
  16. if($data['self_rules'] == 0) {
  17. return '';
  18. }
  19. return json_decode($value, true);
  20. }
  21. public function getCommissionConfigAttr($value, $data)
  22. {
  23. //默认规则
  24. if($data['self_rules'] == 0) {
  25. return '';
  26. }
  27. if(!$data['commission_config']) {
  28. return '';
  29. }
  30. return json_decode($value, true);
  31. }
  32. public function goods()
  33. {
  34. return $this->belongsTo('app\admin\model\shopro\goods\Goods', 'goods_id', 'id');
  35. }
  36. }