feat(events): add event categories and filtering

This commit is contained in:
2026-09-21 09:16:28 -03:00
parent b0702b7e15
commit 79d402e210
13 changed files with 134 additions and 8 deletions

View File

@@ -0,0 +1,41 @@
<?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::create('event_categories', function (Blueprint $table): void {
$table->id();
$table->string('tenant_code');
$table->string('nombre');
$table->timestamps();
$table->foreign('tenant_code')->references('codigo')->on('tenants')->cascadeOnUpdate()->cascadeOnDelete();
$table->unique(['tenant_code', 'nombre']);
});
Schema::table('events', function (Blueprint $table): void {
$table->foreignId('event_category_id')->nullable()->constrained('event_categories')->nullOnDelete();
});
if (DB::table('tenants')->where('codigo', 'onticket')->exists()) {
$now = now();
foreach (['Música', 'Teatro', 'Deportes', 'Infantiles', 'Otros'] as $nombre) {
DB::table('event_categories')->insert([
'tenant_code' => 'onticket', 'nombre' => $nombre,
'created_at' => $now, 'updated_at' => $now,
]);
}
}
}
public function down(): void
{
Schema::table('events', fn (Blueprint $table) => $table->dropConstrainedForeignId('event_category_id'));
Schema::dropIfExists('event_categories');
}
};