diff --git a/app/Models/AgentProduct.php b/app/Models/AgentProduct.php index 6b03135..a8c4d7f 100644 --- a/app/Models/AgentProduct.php +++ b/app/Models/AgentProduct.php @@ -54,23 +54,17 @@ class AgentProduct extends BaseModel public function setChannelIdAttribute($value) { - if (is_array($value)) { - $this->attributes['channel_id'] = join(',', array_filter($value)); - } + $this->attributes['channel_id'] = is_array($value) ? join(',', array_filter($value)) : $value; } public function setPicturesAttribute($value) { - if (is_array($value)) { - $this->attributes['pictures'] = json_encode(array_filter($value)) ?? ''; - } + $this->attributes['pictures'] = is_array($value) ? (json_encode(array_filter($value)) ?? '[]') : '[]'; } public function setProductIdsAttribute($value) { - if (is_array($value)) { - $this->attributes['product_ids'] = join(',', array_filter($value)); - } + $this->attributes['product_ids'] = is_array($value) ? join(',', array_filter($value)) : $value; } // 获取所有产品图片