RechargeChannelGroup.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\SoftDeletes;
  4. class RechargeChannelGroup extends BaseModel
  5. {
  6. use SoftDeletes;
  7. protected $table = 'recharge_channel_group';
  8. protected $fillable = ['name', 'recharge_type', 'withdraw_type'];
  9. // activity_type 列已停用(原按层级开关活动),不再返回
  10. protected $hidden = ['activity_type'];
  11. // 修改器:将逗号分隔字符串转为数组
  12. public function getRechargeTypeAttribute($value)
  13. {
  14. return $value ? explode(',', $value) : [];
  15. }
  16. // 设置器:将数组转为逗号分隔字符串
  17. public function setRechargeTypeAttribute($value)
  18. {
  19. $this->attributes['recharge_type'] = is_array($value) ? implode(',', $value) : $value;
  20. }
  21. public function getWithdrawTypeAttribute($value)
  22. {
  23. return $value ? explode(',', $value) : [];
  24. }
  25. public function setWithdrawTypeAttribute($value)
  26. {
  27. $this->attributes['withdraw_type'] = is_array($value) ? implode(',', $value) : $value;
  28. }
  29. }