From 6e3dc4ad4b29010652f3c2c8731a8e231365a5e8 Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Tue, 17 May 2022 14:31:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Imports/Product.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Admin/Imports/Product.php b/app/Admin/Imports/Product.php index db20599a..8e7c36aa 100644 --- a/app/Admin/Imports/Product.php +++ b/app/Admin/Imports/Product.php @@ -30,8 +30,13 @@ class Product $category = ProductCategory::where('name', $cells[2])->firstOrFail(); $goods['category_id'] = $category->id; + // 图片组 if ($path = $cells[3]) { - $images = $this->getImageUrlFromPath($path); + if (Str::startsWith($path, ['http://', 'https://'])) { + $images = explode(',', $path); + } else { + $images = $this->getImageUrlFromPath($path); + } if (count($images) > 0) { $goods['cover'] = $images[0]; $goods['images'] = $images; @@ -103,7 +108,7 @@ class Product protected function getImageUrlFromPath($dir) { $disk = Storage::disk('public'); - $files = $disk->files('goods/' . $dir); + $files = $disk->files($dir); $images = []; foreach($files as $filename) {