feat(onticket): add immersive hero configuration and carousel, update tenant seeder and tests
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
DB::transaction(function (): void {
|
||||
$now = now();
|
||||
|
||||
DB::table('storefront_website_types')->updateOrInsert(
|
||||
['codigo' => 'onticket_multi_event'],
|
||||
[
|
||||
'nombre' => 'OnTicket - múltiples eventos',
|
||||
'header_type' => 'immersive',
|
||||
'updated_at' => $now,
|
||||
] + (DB::table('storefront_website_types')->where('codigo', 'onticket_multi_event')->exists()
|
||||
? []
|
||||
: ['created_at' => $now]),
|
||||
);
|
||||
|
||||
$extraKey = [
|
||||
'storefront_website_type_code' => 'onticket_multi_event',
|
||||
'codigo' => 'immersiveHero',
|
||||
];
|
||||
|
||||
DB::table('storefront_website_type_extras')->updateOrInsert(
|
||||
$extraKey,
|
||||
[
|
||||
'nombre' => 'Textos del hero inmersivo',
|
||||
'descripcion' => 'Frase superior, título y descripción de la portada.',
|
||||
'is_required' => false,
|
||||
'config_schema' => json_encode([
|
||||
'request_rules' => [
|
||||
'$' => 'required|array:eyebrow,title,description',
|
||||
'eyebrow' => 'required|string|max:120',
|
||||
'title' => 'required|string|max:120',
|
||||
'description' => 'required|string|max:255',
|
||||
],
|
||||
'transforms' => [],
|
||||
], JSON_THROW_ON_ERROR),
|
||||
'updated_at' => $now,
|
||||
] + (DB::table('storefront_website_type_extras')->where($extraKey)->exists()
|
||||
? []
|
||||
: ['created_at' => $now]),
|
||||
);
|
||||
|
||||
$tenant = DB::table('tenants')
|
||||
->where('codigo', 'onticket')
|
||||
->whereIn('storefront_website_type_code', ['onticket', 'onticket_multi_event'])
|
||||
->first(['codigo']);
|
||||
|
||||
if ($tenant === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
DB::table('tenants')->where('codigo', $tenant->codigo)->update([
|
||||
'storefront_website_type_code' => 'onticket_multi_event',
|
||||
'display_seach_bar' => true,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
|
||||
$extraId = DB::table('storefront_website_type_extras')
|
||||
->where($extraKey)
|
||||
->value('id');
|
||||
|
||||
if (! DB::table('websites_extras')
|
||||
->where('website_code', $tenant->codigo)
|
||||
->where('website_type_extra_id', $extraId)
|
||||
->exists()) {
|
||||
DB::table('websites_extras')->insert([
|
||||
'website_code' => $tenant->codigo,
|
||||
'website_type_extra_id' => $extraId,
|
||||
'config' => json_encode([
|
||||
'eyebrow' => 'Encendé tu',
|
||||
'title' => 'experiencia',
|
||||
'description' => 'Reservá tu entrada y formá parte',
|
||||
], JSON_THROW_ON_ERROR),
|
||||
'is_enabled' => true,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// This data change is intentionally retained to avoid removing tenant edits.
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$key = ['storefront_website_type_code' => 'onticket_multi_event'];
|
||||
$definitions = DB::table('storefront_website_type_extras')->where($key);
|
||||
|
||||
if ((clone $definitions)->where('codigo', 'immersiveHeroCarousel')->exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((clone $definitions)->where('codigo', 'heroCarousel')->exists()) {
|
||||
(clone $definitions)->where('codigo', 'heroCarousel')->update([
|
||||
'codigo' => 'immersiveHeroCarousel',
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
DB::table('storefront_website_type_extras')->insert([
|
||||
...$key,
|
||||
'codigo' => 'immersiveHeroCarousel',
|
||||
'nombre' => 'Carrusel del hero',
|
||||
'descripcion' => 'Lista ordenada de imágenes del hero.',
|
||||
'is_required' => false,
|
||||
'config_schema' => json_encode([
|
||||
'request_rules' => [
|
||||
'$' => 'required|array|max:10',
|
||||
'$.*' => 'required|image_or_base64|distinct',
|
||||
],
|
||||
'transforms' => [
|
||||
'$.*' => [
|
||||
'handler' => 'attachment',
|
||||
'attachment_type' => 'image',
|
||||
],
|
||||
],
|
||||
], JSON_THROW_ON_ERROR),
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// Preserve configured images and tenant edits.
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! DB::table('tenants')->where('codigo', 'onticket')->exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
DB::transaction(function (): void {
|
||||
$now = now();
|
||||
|
||||
foreach (['Música', 'Teatro', 'Deportes', 'Infantiles', 'Otros'] as $nombre) {
|
||||
$category = ['tenant_code' => 'onticket', 'nombre' => $nombre];
|
||||
|
||||
if (! DB::table('categorias')->where($category)->exists()) {
|
||||
DB::table('categorias')->insert($category + [
|
||||
'is_enabled' => true,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// Retain categories because they may have been edited or assigned to products.
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user