From eb1e4df63fb59057b337ada581e4203ba33f0340 Mon Sep 17 00:00:00 2001 From: ncoronel Date: Thu, 17 Sep 2026 16:02:21 -0300 Subject: [PATCH] feat(tenant): enhance storefront website types with header_type and multi-event support --- .../OnTicketFeaturedGroupController.php | 2 +- .../Tenant/Models/StorefrontWebsiteType.php | 2 +- .../Tenant/Resources/TenantResource.php | 1 + ...eader_type_to_storefront_website_types.php | 22 +++++++++++++++++++ database/seeders/TenantSeeder.php | 6 ++++- database/seeders/WebsiteTypeSeeder.php | 15 +++++++++++-- tests/Feature/Seeders/TenantSeederTest.php | 2 +- .../Feature/Seeders/WebsiteTypeSeederTest.php | 7 +++++- 8 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 database/migrations/2026_09_17_000100_add_header_type_to_storefront_website_types.php diff --git a/app/Domains/Catalog/Controllers/AdminApp/OnTicketFeaturedGroupController.php b/app/Domains/Catalog/Controllers/AdminApp/OnTicketFeaturedGroupController.php index 1a984ef..b5fbfc3 100644 --- a/app/Domains/Catalog/Controllers/AdminApp/OnTicketFeaturedGroupController.php +++ b/app/Domains/Catalog/Controllers/AdminApp/OnTicketFeaturedGroupController.php @@ -58,7 +58,7 @@ class OnTicketFeaturedGroupController extends Controller { $tenant = $request->user()->tenant()->firstOrFail(); - abort_unless($tenant->storefront_website_type_code === 'onticket', 404); + abort_unless(in_array($tenant->storefront_website_type_code, ['onticket', 'onticket_multi_event'], true), 404); return $tenant; } diff --git a/app/Domains/Tenant/Models/StorefrontWebsiteType.php b/app/Domains/Tenant/Models/StorefrontWebsiteType.php index 2235196..efccfba 100644 --- a/app/Domains/Tenant/Models/StorefrontWebsiteType.php +++ b/app/Domains/Tenant/Models/StorefrontWebsiteType.php @@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; -#[Fillable(['codigo', 'nombre'])] +#[Fillable(['codigo', 'nombre', 'header_type'])] class StorefrontWebsiteType extends Model { use HasFactory; diff --git a/app/Domains/Tenant/Resources/TenantResource.php b/app/Domains/Tenant/Resources/TenantResource.php index 31c47bb..8d9aa26 100644 --- a/app/Domains/Tenant/Resources/TenantResource.php +++ b/app/Domains/Tenant/Resources/TenantResource.php @@ -48,6 +48,7 @@ class TenantResource extends JsonResource 'footer_bg_color' => $this->footer_bg_color, 'admin_website_type_code' => $this->admin_website_type_code, 'storefront_website_type_code' => $this->storefront_website_type_code, + 'header_type' => $this->storefrontWebsiteType?->header_type ?? 'standard', 'event_date_text' => $this->event_date_text, 'event' => $this->whenLoaded('eventDates', fn () => $this->event_title === null ? null diff --git a/database/migrations/2026_09_17_000100_add_header_type_to_storefront_website_types.php b/database/migrations/2026_09_17_000100_add_header_type_to_storefront_website_types.php new file mode 100644 index 0000000..afc9e74 --- /dev/null +++ b/database/migrations/2026_09_17_000100_add_header_type_to_storefront_website_types.php @@ -0,0 +1,22 @@ +string('header_type')->default('standard'); + }); + } + + public function down(): void + { + Schema::table('storefront_website_types', function (Blueprint $table): void { + $table->dropColumn('header_type'); + }); + } +}; diff --git a/database/seeders/TenantSeeder.php b/database/seeders/TenantSeeder.php index e822e90..24f185b 100644 --- a/database/seeders/TenantSeeder.php +++ b/database/seeders/TenantSeeder.php @@ -76,7 +76,7 @@ class TenantSeeder extends Seeder 'display_categories' => false, 'display_seach_bar' => false, 'admin_website_type_code' => $onTicketType->codigo, - 'storefront_website_type_code' => $onTicketType->codigo, + 'storefront_website_type_code' => 'onticket_multi_event', 'header_logo' => $this->uploadedImage( 'images/tennants/onticket/onticket_logo.png', 'onticket_logo.png', @@ -103,6 +103,10 @@ class TenantSeeder extends Seeder ]); } + if ($onTicketTenant !== null && $onTicketTenant->storefront_website_type_code === 'onticket') { + $onTicketTenant->update(['storefront_website_type_code' => 'onticket_multi_event']); + } + $this->deleteTenant('sonder'); Tenant::query() diff --git a/database/seeders/WebsiteTypeSeeder.php b/database/seeders/WebsiteTypeSeeder.php index dccbe01..5b6ded7 100644 --- a/database/seeders/WebsiteTypeSeeder.php +++ b/database/seeders/WebsiteTypeSeeder.php @@ -41,7 +41,10 @@ class WebsiteTypeSeeder extends Seeder ], ); - $shopItStorefront = StorefrontWebsiteType::query()->updateOrCreate(['codigo' => 'shopit'], ['nombre' => 'ShopIt']); + $shopItStorefront = StorefrontWebsiteType::query()->updateOrCreate( + ['codigo' => 'shopit'], + ['nombre' => 'ShopIt', 'header_type' => 'standard'], + ); $shopItStorefront->extras()->updateOrCreate( ['codigo' => 'carousel'], @@ -78,7 +81,15 @@ class WebsiteTypeSeeder extends Seeder ], ); - $onTicketStorefront = StorefrontWebsiteType::query()->updateOrCreate(['codigo' => 'onticket'], ['nombre' => 'OnTicket']); + $onTicketStorefront = StorefrontWebsiteType::query()->updateOrCreate( + ['codigo' => 'onticket'], + ['nombre' => 'OnTicket - evento Ășnico', 'header_type' => 'standard'], + ); + + StorefrontWebsiteType::query()->updateOrCreate( + ['codigo' => 'onticket_multi_event'], + ['nombre' => 'OnTicket - mĂșltiples eventos', 'header_type' => 'immersive'], + ); $onTicketStorefront->extras()->updateOrCreate( ['codigo' => 'heroConfig'], diff --git a/tests/Feature/Seeders/TenantSeederTest.php b/tests/Feature/Seeders/TenantSeederTest.php index e2e6074..180ef28 100644 --- a/tests/Feature/Seeders/TenantSeederTest.php +++ b/tests/Feature/Seeders/TenantSeederTest.php @@ -30,7 +30,7 @@ class TenantSeederTest extends TestCase $this->assertSame('onticket', $tenant->client->code); $this->assertSame($websiteType->codigo, $tenant->admin_website_type_code); - $this->assertSame($websiteType->codigo, $tenant->storefront_website_type_code); + $this->assertSame('onticket_multi_event', $tenant->storefront_website_type_code); $this->assertSame($websiteType->nombre, $tenant->nombre); $this->assertSame($websiteType->dominio, $tenant->dominio); $this->assertSame($websiteType->site_title, $tenant->site_title); diff --git a/tests/Feature/Seeders/WebsiteTypeSeederTest.php b/tests/Feature/Seeders/WebsiteTypeSeederTest.php index f7c3380..34ed606 100644 --- a/tests/Feature/Seeders/WebsiteTypeSeederTest.php +++ b/tests/Feature/Seeders/WebsiteTypeSeederTest.php @@ -22,7 +22,7 @@ class WebsiteTypeSeederTest extends TestCase $this->seed(WebsiteTypeSeeder::class); $this->assertSame(2, AdminWebsiteType::query()->count()); - $this->assertSame(2, StorefrontWebsiteType::query()->count()); + $this->assertSame(3, StorefrontWebsiteType::query()->count()); $this->assertSame(5, Attachment::query()->count()); $expectedPresentation = [ @@ -53,6 +53,7 @@ class WebsiteTypeSeederTest extends TestCase $this->assertSame('onticket_favicon.svg', $shopIt->favicon->filename); Storage::disk('s3')->assertExists($shopIt->favicon->path); $shopItStorefront = StorefrontWebsiteType::query()->where('codigo', 'shopit')->with('extras')->sole(); + $this->assertSame('standard', $shopItStorefront->header_type); $this->assertSame(['carousel'], $shopItStorefront->extras->pluck('codigo')->all()); $this->assertSame('Carrusel principal', $shopItStorefront->extras->sole()->nombre); $this->assertSame([ @@ -85,6 +86,10 @@ class WebsiteTypeSeederTest extends TestCase $this->assertSame($shopIt->favicon_id, $onTicket->favicon_id); $this->assertSame('onticket_favicon.svg', $onTicket->favicon->filename); $onTicketStorefront = StorefrontWebsiteType::query()->where('codigo', 'onticket')->with('extras')->sole(); + $this->assertSame('standard', $onTicketStorefront->header_type); + $multiEventStorefront = StorefrontWebsiteType::query()->where('codigo', 'onticket_multi_event')->with('extras')->sole(); + $this->assertSame('immersive', $multiEventStorefront->header_type); + $this->assertCount(0, $multiEventStorefront->extras); $this->assertEqualsCanonicalizing( ['heroConfig', 'eventConfig', 'additionalInfoConfig'], $onTicketStorefront->extras->pluck('codigo')->all(),