6
0
Fork 0

导入商品

release
panliang 2022-05-17 14:31:56 +08:00
parent d38169f74b
commit 6e3dc4ad4b
1 changed files with 7 additions and 2 deletions

View File

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