Merge branch 'tenant/smep' into homo

This commit is contained in:
2026-09-28 19:27:39 +00:00
541 changed files with 6294 additions and 9 deletions

View File

@@ -3,10 +3,10 @@
namespace Database\Seeders;
use App\Domains\Commerce\Catalog\Models\Attribute;
use App\Shared\Enums\FieldType;
use App\Domains\Core\Tenant\Models\Tenant;
use App\Domains\Ticketing\Ticket\Enums\ValidityTimeType;
use App\Domains\Ticketing\Ticket\Models\ValidityTime;
use App\Shared\Enums\FieldType;
use Illuminate\Database\Seeder;
class AttributeSeeder extends Seeder
@@ -25,6 +25,10 @@ class AttributeSeeder extends Seeder
continue;
}
if ($tenant->codigo === 'mutual_smep') {
continue;
}
$this->seedAttribute($tenant, [
'codigo' => 'color',
'nombre' => 'Color',

View File

@@ -29,7 +29,9 @@ class DatabaseSeeder extends Seeder
TenantSeeder::class,
DesfilePuraTendenciaSeeder::class,
AttributeSeeder::class,
MutualSmepAttributeSeeder::class,
CategorySeeder::class,
MutualSmepCategorySeeder::class,
BrandSeeder::class,
ProductCatalogFromImagesSeeder::class,
FiestaFutbolInfantilProductSeeder::class,

View File

@@ -296,6 +296,7 @@ class MenuSeeder extends Seeder
$helpTenantCodes = [
'sonder',
'fiesta_futbol_infantil',
'mutual_smep',
];
$ticketAdminMenuCodes = [
'adminapp.tickets',
@@ -365,6 +366,42 @@ class MenuSeeder extends Seeder
],
],
];
$mutualSmepFrequentlyAskedQuestions = [
[
'pregunta' => '¿Hay algún límite de compra?',
'respuesta' => 'La cantidad disponible depende del stock de cada producto.',
'is_active' => true,
],
[
'pregunta' => '¿Cuáles son los medios de pago disponibles?',
'respuesta' => 'Podés consultar y seleccionar los medios de pago habilitados al finalizar tu compra.',
'is_active' => false,
],
[
'pregunta' => '¿Cómo puedo recibir asesoramiento antes de comprar?',
'respuesta' => 'Podés comunicarte con Mutual SMEP por WhatsApp al +54 9 341 247-4530.',
'is_active' => false,
],
];
$mutualSmepContactContent = [
'whatsapp' => [
'whatsapp_url' => 'https://wa.me/5493412474530',
'whatsapp_label' => 'Chateá con Mutual SMEP',
],
'phone' => '+54 9 341 247-4530',
'locations' => [
'rosario' => [
'label' => 'Rosario',
'addresses' => [
[
'label' => 'Mutual SMEP',
'address' => 'San Lorenzo 1543, Rosario, Santa Fe',
'coordinates' => [-32.9431184, -60.6437991],
],
],
],
],
];
foreach ($tenants as $tenant) {
$menuCodes = $allMenus;
@@ -406,10 +443,14 @@ class MenuSeeder extends Seeder
if (in_array($tenant->codigo, $helpTenantCodes, true)) {
$tenant->menues()->updateExistingPivot('help.faq', [
'static_content' => $frequentlyAskedQuestions,
'static_content' => $tenant->codigo === 'mutual_smep'
? $mutualSmepFrequentlyAskedQuestions
: $frequentlyAskedQuestions,
]);
$tenant->menues()->updateExistingPivot('help.contact', [
'static_content' => $contactContent,
'static_content' => $tenant->codigo === 'mutual_smep'
? $mutualSmepContactContent
: $contactContent,
]);
}
}

View File

@@ -0,0 +1,122 @@
<?php
namespace Database\Seeders;
use App\Domains\Commerce\Catalog\Models\Attribute;
use App\Domains\Core\Tenant\Models\Tenant;
use App\Shared\Enums\FieldType;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class MutualSmepAttributeSeeder extends Seeder
{
private const TENANT_CODE = 'mutual_smep';
/** @var list<array<string, mixed>> */
private const ATTRIBUTES = [
[
'codigo' => 'color',
'nombre' => 'Color',
'metadata_schema' => [
'hex' => ['type' => 'string'],
],
'options' => [
['value' => 'Negro', 'label' => 'Negro', 'metadata' => ['hex' => '#000000']],
['value' => 'Blanco', 'label' => 'Blanco', 'metadata' => ['hex' => '#FFFFFF']],
['value' => 'Gris', 'label' => 'Gris', 'metadata' => ['hex' => '#808080']],
['value' => 'Plata', 'label' => 'Plata', 'metadata' => ['hex' => '#C0C0C0']],
['value' => 'Azul', 'label' => 'Azul', 'metadata' => ['hex' => '#0000FF']],
['value' => 'Rojo', 'label' => 'Rojo', 'metadata' => ['hex' => '#DC3545']],
['value' => 'Rosa', 'label' => 'Rosa', 'metadata' => ['hex' => '#FFC0CB']],
['value' => 'Multicolor', 'label' => 'Multicolor'],
],
],
[
'codigo' => 'medida_cama',
'nombre' => 'Medida',
'options' => [
['value' => 'Cuna', 'label' => 'Cuna'],
['value' => '1 Plaza', 'label' => '1 Plaza'],
['value' => '1 1/2 Plazas', 'label' => '1 1/2 Plazas'],
['value' => '2 Plazas', 'label' => '2 Plazas'],
['value' => '2 1/2 Plazas', 'label' => '2 1/2 Plazas'],
['value' => 'Queen', 'label' => 'Queen'],
['value' => 'King', 'label' => 'King'],
],
],
[
'codigo' => 'almacenamiento',
'nombre' => 'Almacenamiento',
'options' => [
['value' => '128 GB', 'label' => '128 GB'],
['value' => '256 GB', 'label' => '256 GB'],
['value' => '512 GB', 'label' => '512 GB'],
['value' => '1 TB', 'label' => '1 TB'],
],
],
[
'codigo' => 'memoria_ram',
'nombre' => 'Memoria RAM',
'options' => [
['value' => '4 GB', 'label' => '4 GB'],
['value' => '8 GB', 'label' => '8 GB'],
['value' => '16 GB', 'label' => '16 GB'],
],
],
[
'codigo' => 'rodado',
'nombre' => 'Rodado',
'options' => [
['value' => '16', 'label' => '16'],
['value' => '26', 'label' => '26'],
['value' => '29', 'label' => '29'],
],
],
];
public function run(): void
{
if (! Tenant::query()->where('codigo', self::TENANT_CODE)->exists()) {
return;
}
DB::transaction(function (): void {
foreach (self::ATTRIBUTES as $definition) {
$options = $definition['options'];
unset($definition['options']);
$attribute = Attribute::query()->updateOrCreate(
[
'tenant_codigo' => self::TENANT_CODE,
'codigo' => $definition['codigo'],
],
[
...$definition,
'type' => FieldType::Select->value,
'is_required' => false,
'metadata_schema' => $definition['metadata_schema'] ?? null,
],
);
$attribute->options()->delete();
$attribute->options()->createMany(
collect($options)
->values()
->map(fn (array $option, int $index): array => [
...$option,
'sort_order' => $index + 1,
])
->all()
);
}
});
}
public function down(): void
{
Attribute::query()
->where('tenant_codigo', self::TENANT_CODE)
->whereIn('codigo', array_column(self::ATTRIBUTES, 'codigo'))
->delete();
}
}

View File

@@ -0,0 +1,123 @@
<?php
namespace Database\Seeders;
use App\Domains\Commerce\Catalog\Models\Category;
use App\Domains\Core\Tenant\Models\Tenant;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class MutualSmepCategorySeeder extends Seeder
{
private const TENANT_CODE = 'mutual_smep';
/** @var array<string, list<string>> */
private const CATEGORIES = [
'Dormitorio y Blanco' => [
'Colchones',
'Bases y Sommiers',
'Acolchados y Edredones',
'Frazadas y Mantas',
'Infantil y Cuna',
],
'Electrodomésticos' => [
'Heladeras',
'Lavarropas y Secarropas',
'Cocinas',
'Microondas',
'Hornos Eléctricos',
'Calefones y Termotanques',
'Purificadores y Extractores de Cocina',
'Preparación de Alimentos',
'Café y Desayuno',
'Freidoras y Cocción',
'Cuidado Personal',
'Limpieza y Planchado',
],
'Climatización' => [
'Aires Acondicionados',
'Calefactores a Gas con Salida',
'Calefactores a Gas sin Salida',
'Calefacción Eléctrica',
],
'Tecnología' => [
'Celulares',
'Notebooks',
'Smart TV',
'Audio',
'Accesorios de Computación',
'Soportes para TV',
],
'Bicicletas y Aire Libre' => [
'Bicicletas Infantiles',
'Bicicletas para Adultos',
'Piletas',
],
'Bazar' => [
'Termos',
],
];
public function run(): void
{
if (! Tenant::query()->where('codigo', self::TENANT_CODE)->exists()) {
return;
}
DB::transaction(function (): void {
foreach (self::CATEGORIES as $parentName => $subcategoryNames) {
$parent = Category::query()->updateOrCreate(
[
'tenant_code' => self::TENANT_CODE,
'nombre' => $parentName,
],
[
'categoria_id' => null,
'is_enabled' => true,
],
);
foreach ($subcategoryNames as $subcategoryName) {
Category::query()->updateOrCreate(
[
'tenant_code' => self::TENANT_CODE,
'nombre' => $subcategoryName,
],
[
'categoria_id' => $parent->id,
'is_enabled' => true,
],
);
}
}
});
}
public function down(): void
{
DB::transaction(function (): void {
foreach (self::CATEGORIES as $parentName => $subcategoryNames) {
$parent = Category::query()
->where('tenant_code', self::TENANT_CODE)
->where('nombre', $parentName)
->whereNull('categoria_id')
->first();
if (! $parent instanceof Category) {
continue;
}
Category::query()
->where('tenant_code', self::TENANT_CODE)
->where('categoria_id', $parent->id)
->whereIn('nombre', $subcategoryNames)
->whereDoesntHave('subCategories')
->delete();
if (! $parent->subCategories()->exists()) {
$parent->delete();
}
}
});
}
}