diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml index 6281a18..97496f4 100644 --- a/.github/workflows/laravel.yml +++ b/.github/workflows/laravel.yml @@ -32,6 +32,6 @@ jobs: env: DB_CONNECTION: sqlite DB_DATABASE: database/database.sqlite - run: php artisan migrate --seed + run: PIC_SEED=0 php artisan migrate --seed - name: Execute tests (Unit and Feature tests) via PHPUnit run: vendor/bin/phpunit diff --git a/database/seeders/PostSeeder.php b/database/seeders/PostSeeder.php index 66fa042..531d762 100755 --- a/database/seeders/PostSeeder.php +++ b/database/seeders/PostSeeder.php @@ -87,8 +87,10 @@ class PostSeeder extends Seeder $p->hash = date('Ym') . str_pad(dechex(crc32($p->slug)), 8, '0', STR_PAD_LEFT); $p->save(); $p->categories()->sync([$item['category_id']]); - $num = rand(1, 6); - $p->addMedia(__DIR__ . "/img/$num/$num.jpg")->preservingOriginal()->toMediaCollection(); + if (env('PIC_SEED') != 0){ + $num = rand(1, 6); + $p->addMedia(__DIR__ . "/img/$num/$num.jpg")->preservingOriginal()->toMediaCollection(); + } $p->save(); } } diff --git a/database/seeders/ProductSeeder.php b/database/seeders/ProductSeeder.php index e6fd5d3..de3d93c 100755 --- a/database/seeders/ProductSeeder.php +++ b/database/seeders/ProductSeeder.php @@ -74,10 +74,12 @@ class ProductSeeder extends Seeder $plan = 6; } $product->categories()->sync($plans[$plan]['cats']); - $num = rand(1, $plans[$plan]['max']); - $product->addMedia($plans[$plan]['dir'] . "$num.jpg")->preservingOriginal()->toMediaCollection(); - $num = rand(1, $plans[$plan]['max']); - $product->addMedia($plans[$plan]['dir'] . "$num.jpg")->preservingOriginal()->toMediaCollection(); + if (env('PIC_SEED') != 0){ + $num = rand(1, $plans[$plan]['max']); + $product->addMedia($plans[$plan]['dir'] . "$num.jpg")->preservingOriginal()->toMediaCollection(); + $num = rand(1, $plans[$plan]['max']); + $product->addMedia($plans[$plan]['dir'] . "$num.jpg")->preservingOriginal()->toMediaCollection(); + } $product->cat_id = $plans[$plan]['main']; $product->save(); }