| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace App\Models;
- class RechargeChannelGroup extends BaseModel
- {
- protected $table = 'recharge_channel_group';
- protected $fillable = ['name', 'recharge_type', 'withdraw_type', 'activity_type'];
- protected $hidden = [];
- // 修改器:将逗号分隔字符串转为数组
- public function getRechargeTypeAttribute($value)
- {
- return $value ? explode(',', $value) : [];
- }
- // 设置器:将数组转为逗号分隔字符串
- public function setRechargeAttribute($value)
- {
- $this->attributes['recharge_type'] = is_array($value) ? implode(',', $value) : $value;
- }
- public function getWithdrawTypeAttribute($value)
- {
- return $value ? explode(',', $value) : [];
- }
- public function setWithdrawAttribute($value)
- {
- $this->attributes['withdraw_type'] = is_array($value) ? implode(',', $value) : $value;
- }
- public function getActivityTypeAttribute($value)
- {
- return $value ? explode(',', $value) : [];
- }
- public function setActivityAttribute($value)
- {
- if (!$value)
- return '';
- $this->attributes['activity_type'] = is_array($value) ? implode(',', $value) : $value;
- }
- }
|