feat(event): add EventDateTextFormatter for formatting event dates; update Tenant model and resource to include event_date_text; create migration for event_date_text column; enhance tests for event date formatting and tenant updates

This commit is contained in:
2026-08-10 10:42:12 -03:00
parent 1cd60f7021
commit 4aaa66dc38
9 changed files with 181 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
<?php
use App\Domains\Event\Services\EventDateTextFormatter;
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('tenants', function (Blueprint $table): void {
$table->text('event_date_text')->nullable()->after('event_location');
});
$formatter = new EventDateTextFormatter;
DB::table('tenants')->orderBy('id')->each(function (object $tenant) use ($formatter): void {
$dates = DB::table('event_dates')
->where('tenant_code', $tenant->codigo)
->orderBy('date')
->pluck('date');
DB::table('tenants')->where('id', $tenant->id)->update([
'event_date_text' => $formatter->format($dates),
]);
});
}
public function down(): void
{
Schema::table('tenants', function (Blueprint $table): void {
$table->dropColumn('event_date_text');
});
}
};