feat(seeder): enhance FiestaFutbolInfantilProductSeeder to manage event dates and validity times
This commit is contained in:
@@ -10,8 +10,11 @@ use App\Domains\Catalog\Models\CatalogItem;
|
||||
use App\Domains\Catalog\Models\Category;
|
||||
use App\Domains\Catalog\Models\FeaturedGroup;
|
||||
use App\Domains\Catalog\Services\CatalogService;
|
||||
use App\Domains\Event\Models\EventDate;
|
||||
use App\Domains\Tenant\Models\Tenant;
|
||||
use App\Domains\Ticket\Enums\TicketGenerationPolicy;
|
||||
use App\Domains\Ticket\Enums\ValidityTimeType;
|
||||
use App\Domains\Ticket\Models\ValidityTime;
|
||||
use Illuminate\Database\Seeder;
|
||||
use RuntimeException;
|
||||
|
||||
@@ -47,13 +50,30 @@ class FiestaFutbolInfantilProductSeeder extends Seeder
|
||||
'event_location' => 'Sunchales, Santa Fe',
|
||||
]);
|
||||
|
||||
$existingValidityTimeIds = $tenant->eventDates()->pluck('validity_time_id');
|
||||
$tenant->eventDates()->delete();
|
||||
ValidityTime::query()->whereKey($existingValidityTimeIds)->delete();
|
||||
|
||||
$eventDates = collect(['2026-10-09', '2026-10-10', '2026-10-11', '2026-10-12'])
|
||||
->map(fn (string $date) => $tenant->eventDates()->create([
|
||||
'date' => $date,
|
||||
'time_start' => '00:00:00',
|
||||
'time_end' => '23:59:59',
|
||||
]));
|
||||
->map(function (string $date) use ($tenant): EventDate {
|
||||
$validityTime = ValidityTime::query()->create([
|
||||
'type' => ValidityTimeType::FixedWindow,
|
||||
'start_time' => null,
|
||||
'end_time' => null,
|
||||
'fixed_starts_at' => $date.' 00:00:00',
|
||||
'fixed_expires_at' => $date.' 23:59:59',
|
||||
]);
|
||||
|
||||
$eventDate = new EventDate;
|
||||
$eventDate->forceFill([
|
||||
'date' => $date,
|
||||
'time_start' => '00:00:00',
|
||||
'time_end' => '23:59:59',
|
||||
'validity_time_id' => $validityTime->id,
|
||||
]);
|
||||
|
||||
return $tenant->eventDates()->save($eventDate);
|
||||
});
|
||||
$dateIds = $eventDates->pluck('id')->map(fn ($id): int => (int) $id)->values();
|
||||
|
||||
$this->createProduct($tenant, [
|
||||
|
||||
@@ -128,8 +128,8 @@ class TenantSeeder extends Seeder
|
||||
'button_text' => 'Comprar entradas',
|
||||
'button_href' => '/tickets',
|
||||
'background_image_id' => $this->uploadedImage(
|
||||
'images/tennants/fiesta_futbol_infantil/futbol_infantil_hero.jpg',
|
||||
'futbol_infantil_hero.jpg',
|
||||
'images/tennants/fiesta_futbol_infantil/futbol_infantil_hero.png',
|
||||
'futbol_infantil_hero.png',
|
||||
),
|
||||
],
|
||||
'eventConfig' => [
|
||||
|
||||
Reference in New Issue
Block a user