feat(event): restore event model and migrate tenant event data

This commit is contained in:
2026-09-18 11:31:51 -03:00
parent 1e67d27a90
commit 0170a2eabb
13 changed files with 339 additions and 81 deletions

View File

@@ -56,15 +56,12 @@ class DesfilePuraTendenciaSeeder extends Seeder
private function createTenant(Client $client): void
{
$this->tenantService->create([
$tenant = $this->tenantService->create([
'client_id' => $client->id,
'codigo' => self::TENANT_CODE,
'nombre' => 'Desfile Pura Tendencia',
'dominio' => 'desfile-pura-tendencia.localhost',
'site_title' => 'Desfile Pura Tendencia',
'event_title' => 'Desfile Pura Tendencia',
'event_location' => 'Salón Centro Recreativo Luz y Fuerza',
'event_date_text' => '16 de Octubre 2026',
'primary_color' => '#BA69A9',
'secondary_color' => '#A0A0A0',
'danger_color' => '#FF8888',
@@ -107,6 +104,14 @@ class DesfilePuraTendenciaSeeder extends Seeder
],
],
]);
$event = $tenant->events()->create([
'title' => 'Desfile Pura Tendencia',
'location' => 'Salón Centro Recreativo Luz y Fuerza',
'date_text' => '16 de Octubre 2026',
'published_at' => now(),
]);
$tenant->update(['active_event_id' => $event->id]);
}
private function createEventDate(): void
@@ -124,6 +129,7 @@ class DesfilePuraTendenciaSeeder extends Seeder
DB::table('event_dates')->insert([
'tenant_code' => self::TENANT_CODE,
'event_id' => DB::table('events')->where('tenant_code', self::TENANT_CODE)->value('id'),
'validity_time_id' => $validityTimeId,
'date' => '2026-10-16',
'time_start' => '20:30:00',

View File

@@ -44,17 +44,37 @@ class FiestaFutbolInfantilProductSeeder extends Seeder
'tenant_code' => $tenant->codigo,
]));
$tenant->update([
'event_title' => 'Fiesta Nacional del Fútbol Infantil',
'event_location' => 'Sunchales, Santa Fe',
]);
$event = $tenant->events()->firstOrCreate(
['title' => 'Fiesta Nacional del Fútbol Infantil'],
['location' => 'Sunchales, Santa Fe', 'published_at' => now()],
);
$event->update(['location' => 'Sunchales, Santa Fe']);
if ($tenant->storefront_website_type_code === 'onticket' && $tenant->active_event_id === null) {
$tenant->update(['active_event_id' => $event->id]);
}
$existingCodes = $event->socialMedia()->pluck('social_media.code')->all();
$missingSocialMedia = $tenant->socialMedia()
->get()
->reject(fn ($network): bool => in_array($network->code, $existingCodes, true))
->mapWithKeys(fn ($network): array => [
$network->code => [
'url' => $network->pivot->url,
'orden' => $network->pivot->orden,
],
])
->all();
if ($missingSocialMedia !== []) {
$event->socialMedia()->syncWithoutDetaching($missingSocialMedia);
}
$existingValidityTimeIds = $tenant->eventDates()->pluck('validity_time_id');
$tenant->eventDates()->delete();
$event->dates()->delete();
ValidityTime::query()->whereKey($existingValidityTimeIds)->delete();
$eventDates = collect(['2026-10-09', '2026-10-10', '2026-10-11', '2026-10-12'])
->map(function (string $date) use ($tenant): EventDate {
->map(function (string $date) use ($tenant, $event): EventDate {
$validityTime = ValidityTime::query()->create([
'type' => ValidityTimeType::FixedWindow,
'start_time' => null,
@@ -69,9 +89,10 @@ class FiestaFutbolInfantilProductSeeder extends Seeder
'time_start' => '00:00:00',
'time_end' => '23:59:59',
'validity_time_id' => $validityTime->id,
'tenant_code' => $tenant->codigo,
]);
return $tenant->eventDates()->save($eventDate);
return $event->dates()->save($eventDate);
});
$dateIds = $eventDates->pluck('id')->map(fn ($id): int => (int) $id)->values();