feat(tenant): enhance storefront website types with header_type and multi-event support
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('storefront_website_types', function (Blueprint $table): void {
|
||||
$table->string('header_type')->default('standard');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('storefront_website_types', function (Blueprint $table): void {
|
||||
$table->dropColumn('header_type');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -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()
|
||||
|
||||
@@ -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'],
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user