feat(cart): implement cart editing policies and update related functionality

This commit is contained in:
2026-08-19 10:15:37 -03:00
parent 67e6211857
commit 014b5bb012
20 changed files with 305 additions and 39 deletions

View File

@@ -0,0 +1,56 @@
<?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
{
/** @var array<string, string> */
private const TENANT_POLICIES = [
'sonder' => 'quantity_and_remove',
'fiesta_futbol_infantil' => 'full',
'desfile_pura_tendencia' => 'disabled',
];
public function up(): void
{
Schema::table('tenants', function (Blueprint $table): void {
$table->string('cart_editing_policy')
->default('full')
->after('display_cart');
});
DB::table('tenants')
->where('cart_editing_enabled', false)
->update(['cart_editing_policy' => 'disabled']);
foreach (self::TENANT_POLICIES as $tenantCode => $policy) {
DB::table('tenants')
->where('codigo', $tenantCode)
->update(['cart_editing_policy' => $policy]);
}
Schema::table('tenants', function (Blueprint $table): void {
$table->dropColumn('cart_editing_enabled');
});
}
public function down(): void
{
Schema::table('tenants', function (Blueprint $table): void {
$table->boolean('cart_editing_enabled')
->default(true)
->after('display_cart');
});
DB::table('tenants')
->where('cart_editing_policy', 'disabled')
->update(['cart_editing_enabled' => false]);
Schema::table('tenants', function (Blueprint $table): void {
$table->dropColumn('cart_editing_policy');
});
}
};