Fixup Seeds
This commit is contained in:
parent
a64b6253c4
commit
c2d9b3d4f0
16 changed files with 117 additions and 29 deletions
|
|
@ -89,7 +89,7 @@ trait BaseEnum
|
|||
/**
|
||||
* Get enums.
|
||||
*
|
||||
* @return array
|
||||
* @return array<self>
|
||||
*/
|
||||
public static function toArray(): array
|
||||
{
|
||||
|
|
|
|||
30
database/migrations/2030_01_01_000001_mandatory_seeds.php
Normal file
30
database/migrations/2030_01_01_000001_mandatory_seeds.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
use Database\Seeders\MandatorySeeder;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Artisan::call('db:seed', [
|
||||
'class' => MandatorySeeder::class
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
};
|
||||
|
|
@ -14,15 +14,8 @@ class DatabaseSeeder extends Seeder
|
|||
public function run()
|
||||
{
|
||||
$this->call([
|
||||
ExpertiseProductSeeder::class,
|
||||
SlideSeeder::class,
|
||||
RangeSeeder::class,
|
||||
SubrangeSeeder::class,
|
||||
ProductSeeder::class,
|
||||
AdviceSeeder::class,
|
||||
NewsCategorySeeder::class,
|
||||
NewsSeeder::class,
|
||||
StaticPageSeeder::class,
|
||||
MandatorySeeder::class,
|
||||
DevelopmentSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
namespace Database\Seeders\Development;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Models\Advice;
|
||||
|
|
@ -17,6 +17,7 @@ class AdviceSeeder extends Seeder
|
|||
*/
|
||||
public function run()
|
||||
{
|
||||
// @phpstan-ignore-next-line
|
||||
Advice::factory(50)->make()->each(function (Advice $advice) {
|
||||
$advice->picture = FileStorageHelper::storeFile(
|
||||
$advice,
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
namespace Database\Seeders\Development;
|
||||
|
||||
use App\Enums\ExpertiseProducts\ExpertiseProductPageEnum;
|
||||
use App\Models\ExpertiseProduct;
|
||||
|
|
@ -15,12 +15,13 @@ class ExpertiseProductSeeder extends Seeder
|
|||
*/
|
||||
public function run()
|
||||
{
|
||||
$nbPages = count(ExpertiseProductPageEnum::toArray());
|
||||
$exprtPageTypeEnumList = ExpertiseProductPageEnum::toArray();
|
||||
|
||||
for ($ii = 0; $ii < $nbPages; $ii++) {
|
||||
foreach ($exprtPageTypeEnumList as $enum) {
|
||||
ExpertiseProduct::factory(rand(0, 3))->make()->each(
|
||||
function (ExpertiseProduct $expertiseProduct) use ($ii) {
|
||||
$expertiseProduct->page = $ii;
|
||||
// @phpstan-ignore-next-line
|
||||
function (ExpertiseProduct $expertiseProduct) use ($enum) {
|
||||
$expertiseProduct->page = $enum;
|
||||
$expertiseProduct->saveQuietly();
|
||||
}
|
||||
);
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
namespace Database\Seeders\Development;
|
||||
|
||||
use App\Models\NewsCategory;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
|
@ -14,6 +14,7 @@ class NewsCategorySeeder extends Seeder
|
|||
*/
|
||||
public function run()
|
||||
{
|
||||
// @phpstan-ignore-next-line
|
||||
NewsCategory::factory(5)->make()->each(function (NewsCategory $newsCategory) {
|
||||
$newsCategory->saveQuietly();
|
||||
});
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
namespace Database\Seeders\Development;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Models\News;
|
||||
|
|
@ -17,6 +17,7 @@ class NewsSeeder extends Seeder
|
|||
*/
|
||||
public function run()
|
||||
{
|
||||
// @phpstan-ignore-next-line
|
||||
News::factory(10)->make()->each(function (News $news) {
|
||||
$news->picture = FileStorageHelper::storeFile(
|
||||
$news,
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
namespace Database\Seeders\Development;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Models\Product;
|
||||
|
|
@ -18,6 +18,7 @@ class ProductSeeder extends Seeder
|
|||
{
|
||||
$subranges = Subrange::query()->get();
|
||||
$jj = 1;
|
||||
// @phpstan-ignore-next-line
|
||||
Product::factory(150)->make()->each(function (Product $product) use (&$jj, $subranges) {
|
||||
$slider_pictures = [];
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
namespace Database\Seeders\Development;
|
||||
|
||||
use App\Lib\Helpers\FileStorageHelper;
|
||||
use App\Models\Range;
|
||||
|
|
@ -16,6 +16,7 @@ class RangeSeeder extends Seeder
|
|||
public function run()
|
||||
{
|
||||
$ii = 1;
|
||||
// @phpstan-ignore-next-line
|
||||
Range::factory(5)->make()->each(function (Range $range) use (&$ii) {
|
||||
$range->picture = FileStorageHelper::storeFile(
|
||||
$range,
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
namespace Database\Seeders\Development;
|
||||
|
||||
use App\Models\Slide;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
|
@ -18,6 +18,7 @@ class SlideSeeder extends Seeder
|
|||
$ii = 1;
|
||||
Slide::truncate();
|
||||
Slide::factory(4)->make()
|
||||
// @phpstan-ignore-next-line
|
||||
->each(function (Slide $slide) use (&$ii) {
|
||||
$slide->picture = new SplFileInfo(\resource_path(
|
||||
'../database/factories/assets/slide/image-slide-950x700-0' . $ii . '.jpg'
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
namespace Database\Seeders\Development;
|
||||
|
||||
use App\Models\Range;
|
||||
use App\Models\Subrange;
|
||||
|
|
@ -111,10 +111,12 @@ class SubrangeSeeder extends Seeder
|
|||
mt_srand(crc32(microtime()));
|
||||
|
||||
Range::query()->get()->each(function (Range $range) {
|
||||
Subrange::factory(mt_rand(2, 5))->make()->each(function (Subrange $subrange) use ($range) {
|
||||
$subrange->range()->associate($range);
|
||||
$subrange->saveOrFail();
|
||||
});
|
||||
Subrange::factory(mt_rand(2, 5))->make()
|
||||
// @phpstan-ignore-next-line
|
||||
->each(function (Subrange $subrange) use ($range) {
|
||||
$subrange->range()->associate($range);
|
||||
$subrange->saveOrFail();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
namespace Database\Seeders\Development;
|
||||
|
||||
use App\Models\Tag;
|
||||
use Illuminate\Database\Seeder;
|
||||
35
database/seeders/DevelopmentSeeder.php
Normal file
35
database/seeders/DevelopmentSeeder.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Database\Seeders\Development\AdviceSeeder;
|
||||
use Database\Seeders\Development\ExpertiseProductSeeder;
|
||||
use Database\Seeders\Development\NewsCategorySeeder;
|
||||
use Database\Seeders\Development\NewsSeeder;
|
||||
use Database\Seeders\Development\ProductSeeder;
|
||||
use Database\Seeders\Development\RangeSeeder;
|
||||
use Database\Seeders\Development\SlideSeeder;
|
||||
use Database\Seeders\Development\SubrangeSeeder;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DevelopmentSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$this->call([
|
||||
ExpertiseProductSeeder::class,
|
||||
SlideSeeder::class,
|
||||
RangeSeeder::class,
|
||||
SubrangeSeeder::class,
|
||||
ProductSeeder::class,
|
||||
AdviceSeeder::class,
|
||||
NewsCategorySeeder::class,
|
||||
NewsSeeder::class
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
namespace Database\Seeders\Mandatory;
|
||||
|
||||
use App\Enums\StaticPageType;
|
||||
use App\Models\StaticPage;
|
||||
21
database/seeders/MandatorySeeder.php
Normal file
21
database/seeders/MandatorySeeder.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Database\Seeders\Mandatory\StaticPageSeeder;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class MandatorySeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$this->call([
|
||||
StaticPageSeeder::class
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
use App\Http\Controllers\Fo\StaticPageController;
|
||||
use App\Http\Controllers\Bo\StaticPageController;
|
||||
use App\Http\Controllers\Fo\ActivitiesController;
|
||||
use App\Http\Controllers\Fo\AdnController;
|
||||
use App\Http\Controllers\Fo\ContactController;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue