refactor(catalog): add ticket_label to item attributes and update related logic
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?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->string('ticket_label', 100)->nullable()->after('show_in_selector');
|
||||
});
|
||||
|
||||
foreach (['sector' => 'Lado', 'fila' => 'Fila', 'asiento' => 'Asiento'] as $code => $label) {
|
||||
$itemAttributeIds = DB::table('item_attributes')
|
||||
->join('catalog_items', 'catalog_items.id', '=', 'item_attributes.catalog_item_id')
|
||||
->join('attribute', 'attribute.id', '=', 'item_attributes.attribute_id')
|
||||
->where('catalog_items.tenant_code', 'desfile_pura_tendencia')
|
||||
->where('attribute.codigo', $code)
|
||||
->pluck('item_attributes.id');
|
||||
|
||||
DB::table('item_attributes')
|
||||
->whereIn('id', $itemAttributeIds)
|
||||
->update(['ticket_label' => $label]);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('item_attributes', function (Blueprint $table): void {
|
||||
$table->dropColumn('ticket_label');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -170,6 +170,11 @@ class DesfilePuraTendenciaSeeder extends Seeder
|
||||
'inventory_subject' => InventorySubject::Seat->value,
|
||||
'has_tickets' => true,
|
||||
'attribute_codes' => array_keys($attributes),
|
||||
'ticket_attribute_labels' => [
|
||||
'sector' => 'Lado',
|
||||
'fila' => 'Fila',
|
||||
'asiento' => 'Asiento',
|
||||
],
|
||||
'variants' => $this->entryVariants(),
|
||||
'images' => [
|
||||
$this->uploadedImage(
|
||||
|
||||
Reference in New Issue
Block a user