From e34ca79fe1ae4779f8892f82c7bcc9a004addf59 Mon Sep 17 00:00:00 2001 From: A1Gard Date: Tue, 19 Nov 2024 15:50:50 +0330 Subject: [PATCH] added svg support to image seeder --- app/Console/Commands/SeedingImage.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Console/Commands/SeedingImage.php b/app/Console/Commands/SeedingImage.php index d478c4f..6c77a17 100644 --- a/app/Console/Commands/SeedingImage.php +++ b/app/Console/Commands/SeedingImage.php @@ -56,6 +56,8 @@ class SeedingImage extends Command } break; case 'Category': + $svgs = \File::files(__DIR__ . '/../../../database/seeders/images/svg'); + foreach (Category::all() as $item) { $this->info('Category: ' . $item->name . ' adding image...'); shuffle($images); @@ -75,6 +77,9 @@ class SeedingImage extends Command ->optimize() ->format('webp'); $i->save(storage_path() . '/app/public/categories/optimized-'. $item->bg); + shuffle($svgs); + \File::copy($svgs[0]->getRealPath(),storage_path().'/app/public/categories/' . $svgs[0]->getFilename()); + $item->svg = $svgs[0]->getFilename(); $item->save(); } break;