feat(catalog): add group_order field to catalog items and update related logic

This commit is contained in:
2026-08-25 10:45:12 -03:00
parent 6b06028771
commit 87a4fa6288
9 changed files with 84 additions and 2 deletions

View File

@@ -0,0 +1,53 @@
<?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('catalog_items', function (Blueprint $table): void {
$table->unsignedInteger('group_order')->default(0)->after('nombre');
});
$footballOrder = [
1 => [
'slugs' => ['camiseta', 'camiseta-oficial-fnfi'],
'names' => ['Camiseta', 'CAMISETA OFICIAL FNFI'],
],
2 => [
'slugs' => ['alojamiento', 'camping'],
'names' => ['Alojamiento', 'CAMPING'],
],
3 => [
'slugs' => ['abono'],
'names' => ['Abono', 'ABONO'],
],
4 => [
'slugs' => ['comida'],
'names' => ['Comida', 'COMIDA'],
],
];
foreach ($footballOrder as $order => $identifiers) {
DB::table('catalog_items')
->where('tenant_code', 'fiesta_futbol_infantil')
->where(function ($query) use ($identifiers): void {
$query
->whereIn('slug', $identifiers['slugs'])
->orWhereIn('nombre', $identifiers['names']);
})
->update(['group_order' => $order]);
}
}
public function down(): void
{
Schema::table('catalog_items', function (Blueprint $table): void {
$table->dropColumn('group_order');
});
}
};

View File

@@ -78,6 +78,7 @@ class FiestaFutbolInfantilProductSeeder extends Seeder
$this->createProduct($tenant, [
'slug' => 'camiseta',
'nombre' => 'Camiseta',
'group_order' => 1,
'category_id' => $categories['merchandising']->id,
'precio' => 18000,
'attribute_codes' => ['color', 'talle'],
@@ -92,6 +93,7 @@ class FiestaFutbolInfantilProductSeeder extends Seeder
$this->createProduct($tenant, [
'slug' => 'alojamiento',
'nombre' => 'Alojamiento',
'group_order' => 2,
'category_id' => $categories['alojamientos']->id,
'precio' => 35000,
'attribute_codes' => ['tipo_alojamiento'],
@@ -104,6 +106,7 @@ class FiestaFutbolInfantilProductSeeder extends Seeder
$this->createProduct($tenant, [
'slug' => 'comida',
'nombre' => 'Comida',
'group_order' => 4,
'category_id' => $categories['comidas']->id,
'precio' => 4000,
'attribute_codes' => ['event_date', 'horario', 'servicio'],
@@ -126,6 +129,7 @@ class FiestaFutbolInfantilProductSeeder extends Seeder
$this->createProduct($tenant, [
'slug' => 'abono',
'nombre' => 'Abono',
'group_order' => 3,
'category_id' => $categories['entradas']->id,
'precio' => 40000,
'has_tickets' => true,