| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?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 setRechargeTypeAttribute($value)
- {
- $this->attributes['recharge_type'] = is_array($value) ? implode(',', $value) : $value;
- }
- public function getWithdrawTypeAttribute($value)
- {
- return $value ? explode(',', $value) : [];
- }
- public function setWithdrawTypeAttribute($value)
- {
- $this->attributes['withdraw_type'] = is_array($value) ? implode(',', $value) : $value;
- }
- public function getActivityTypeAttribute($value)
- {
- return $value ? explode(',', $value) : [];
- }
- public function setActivityTypeAttribute($value)
- {
- if (!$value)
- return '';
- $this->attributes['activity_type'] = is_array($value) ? implode(',', $value) : $value;
- }
- public static function getActivityType($id) {
- $id = $id > 0 ? $id : 1;
- $activity_type = self::where('id', $id)->value('activity_type');
- return $activity_type;
- }
- }
|