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) {