feat: add support for multiple event dates in variants

- Updated the FeaturedGroupService to include 'variants.eventDates' in the items query.
- Introduced a BelongsToMany relationship in EventDate for selected variants.
- Modified PurchaseItemResource and PurchaseItemSnapshotFactory to handle multiple event dates for variants.
- Enhanced StartCheckoutService to load event dates for variants.
- Updated TicketGeneratorService to accommodate event dates in ticket generation.
- Created migrations to support multi-value event dates and allow multiple variant values per attribute.
- Adjusted seeders to reflect new event date handling and added new attributes.
- Added tests to ensure correct functionality for multi-date variants and their integration with ticket generation.
This commit is contained in:
2026-08-07 11:57:38 -03:00
parent 91af233941
commit 21b70777f2
22 changed files with 516 additions and 413 deletions

View File

@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('item_attributes', function (Blueprint $table): void {
$table->boolean('allow_multi_select')->default(false)->after('attribute_id');
});
Schema::create('variant_event_dates', function (Blueprint $table): void {
$table->foreignId('variant_id')->constrained('variantes')->cascadeOnDelete();
$table->foreignId('event_date_id')->constrained('event_dates')->cascadeOnDelete();
$table->primary(['variant_id', 'event_date_id']);
$table->index(['event_date_id', 'variant_id']);
});
DB::table('variantes')
->whereNotNull('event_date_id')
->orderBy('id')
->each(function (object $variant): void {
DB::table('variant_event_dates')->insertOrIgnore([
'variant_id' => $variant->id,
'event_date_id' => $variant->event_date_id,
]);
});
}
public function down(): void
{
Schema::dropIfExists('variant_event_dates');
Schema::table('item_attributes', function (Blueprint $table): void {
$table->dropColumn('allow_multi_select');
});
}
};

View File

@@ -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('variant_values', function (Blueprint $table): void {
$table->dropUnique('variant_values_variant_id_item_attribute_id_unique');
});
}
public function down(): void
{
Schema::table('variant_values', function (Blueprint $table): void {
$table->unique(['variant_id', 'item_attribute_id']);
});
}
};