From 99021a94fc659573996a28010f2fda6b9b3b42d9 Mon Sep 17 00:00:00 2001 From: Mike Date: Mon, 7 Sep 2020 17:49:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0detal=20imgs=20url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Model/v3/Goods.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/Model/v3/Goods.php b/app/Model/v3/Goods.php index 2c89408..84daf35 100644 --- a/app/Model/v3/Goods.php +++ b/app/Model/v3/Goods.php @@ -12,6 +12,7 @@ use Hyperf\Database\Model\SoftDeletes; use Hyperf\Utils\ApplicationContext; use Hyperf\Di\Annotation\Inject; use App\Constants\v3\Goods as GoodsConstants; +use Hyperf\Utils\Collection; /** */ @@ -53,6 +54,7 @@ class Goods extends Model 'cart_num', 'is_effective', 'noneffective_note', + 'details_imgs_url', ]; protected function boot(): void @@ -108,6 +110,16 @@ class Goods extends Model return ''; } + public function getDetailsImgsUrlAttribute() + { + $details_imgs = $this->details_imgs; + $img_host = config('alioss.img_host').'/'; + + return collect($details_imgs)->map(function($item) use ($img_host){ + return $img_host . $item; + }); + } + public function store() { return $this->belongsTo(Store::class, 'store_id', 'id');