feat(events): add event categories and filtering
This commit is contained in:
@@ -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');
|
||||
}
|
||||
};
|
||||
@@ -113,6 +113,10 @@ class TenantSeeder extends Seeder
|
||||
|
||||
$onTicketTenant = Tenant::query()->where('codigo', 'onticket')->firstOrFail();
|
||||
|
||||
foreach (['Música', 'Teatro', 'Deportes', 'Infantiles', 'Otros'] as $nombre) {
|
||||
$onTicketTenant->eventCategories()->firstOrCreate(['nombre' => $nombre]);
|
||||
}
|
||||
|
||||
if ($onTicketTenant->storefront_website_type_code === 'onticket_multi_event' && ! $onTicketTenant->display_seach_bar) {
|
||||
$onTicketTenant->update(['display_seach_bar' => true]);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ class TestEventsSeeder extends Seeder
|
||||
$events = [
|
||||
[
|
||||
'title' => '[Prueba] Noche de Música en Vivo',
|
||||
'category' => 'Música',
|
||||
'subtitle' => 'Una noche para cantar y bailar',
|
||||
'description' => 'Evento de prueba para explorar la cartelera de OnTicket.',
|
||||
'location' => 'Teatro Broadway, Rosario',
|
||||
@@ -30,6 +31,7 @@ class TestEventsSeeder extends Seeder
|
||||
],
|
||||
[
|
||||
'title' => '[Prueba] Festival de Sabores',
|
||||
'category' => 'Otros',
|
||||
'subtitle' => 'Gastronomía y música para toda la familia',
|
||||
'description' => 'Evento de prueba con dos jornadas disponibles.',
|
||||
'location' => 'Parque de España, Rosario',
|
||||
@@ -41,6 +43,7 @@ class TestEventsSeeder extends Seeder
|
||||
],
|
||||
[
|
||||
'title' => '[Prueba] Stand Up en el Centro',
|
||||
'category' => 'Teatro',
|
||||
'subtitle' => 'Humor para compartir',
|
||||
'description' => 'Evento de prueba para visualizar distintas propuestas.',
|
||||
'location' => 'Centro Cultural La Comedia, Rosario',
|
||||
@@ -60,9 +63,16 @@ class TestEventsSeeder extends Seeder
|
||||
'description' => $definition['description'],
|
||||
'location' => $definition['location'],
|
||||
'published_at' => now(),
|
||||
'event_category_id' => $tenant->eventCategories()
|
||||
->where('nombre', $definition['category'])->value('id'),
|
||||
],
|
||||
);
|
||||
|
||||
if ($event->event_category_id === null) {
|
||||
$event->update(['event_category_id' => $tenant->eventCategories()
|
||||
->where('nombre', $definition['category'])->value('id')]);
|
||||
}
|
||||
|
||||
if ($event->attachment_id === null) {
|
||||
$path = public_path('images/tennants/onticket/test-events/'.$definition['image']);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user