RechargeChannelGroup.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Models;
  3. class RechargeChannelGroup extends BaseModel
  4. {
  5. protected $table = 'recharge_channel_group';
  6. protected $fillable = ['name', 'recharge_type', 'withdraw_type', 'activity_type'];
  7. protected $hidden = [];
  8. // 修改器:将逗号分隔字符串转为数组
  9. public function getRechargeTypeAttribute($value)
  10. {
  11. return $value ? explode(',', $value) : [];
  12. }
  13. // 设置器:将数组转为逗号分隔字符串
  14. public function setRechargeAttribute($value)
  15. {
  16. $this->attributes['recharge_type'] = is_array($value) ? implode(',', $value) : $value;
  17. }
  18. public function getWithdrawTypeAttribute($value)
  19. {
  20. return $value ? explode(',', $value) : [];
  21. }
  22. public function setWithdrawAttribute($value)
  23. {
  24. $this->attributes['withdraw_type'] = is_array($value) ? implode(',', $value) : $value;
  25. }
  26. public function getActivityTypeAttribute($value)
  27. {
  28. return $value ? explode(',', $value) : [];
  29. }
  30. public function setActivityAttribute($value)
  31. {
  32. if (!$value)
  33. return '';
  34. $this->attributes['activity_type'] = is_array($value) ? implode(',', $value) : $value;
  35. }
  36. }