From 9bd4e129921715e01e490b2e1b8a4e7a9c175e20 Mon Sep 17 00:00:00 2001 From: liapples Date: Thu, 2 Sep 2021 10:19:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=99=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/AgentProduct.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) 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; } // 获取所有产品图片