34 lines
1.2 KiB
PHP
34 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Enums\SeasonalSections\BackgroundEnum;
|
|
use App\Lib\Helpers\FileStorageHelper;
|
|
use App\Models\SeasonalSection;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class SeasonalSectionSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run()
|
|
{
|
|
FileStorageHelper::removeModelFiles(new SeasonalSection());
|
|
$publish_at = now()->subDays(rand(1, 10));
|
|
$unpublish_at = $publish_at->copy()->addDays(rand(10, 20));
|
|
foreach (BackgroundEnum::cases() as $i => $background) {
|
|
SeasonalSection::factory(1)->create([
|
|
'background' => $background,
|
|
'published' => $i === array_key_first(BackgroundEnum::cases()) ? true : false,
|
|
'publish_at' => $publish_at->subMonths(),
|
|
'unpublish_at' => $unpublish_at->subMonths(),
|
|
'picture' => FileStorageHelper::storeFile(new SeasonalSection(), new \SplFileInfo(
|
|
\resource_path('../database/factories/assets/seasonalsections/default-picture-362x542.png')
|
|
)),
|
|
]);
|
|
}
|
|
}
|
|
}
|