diff --git a/app/Domains/Ticketing/Event/Models/Event.php b/app/Domains/Ticketing/Event/Models/Event.php index b792d9a..3f3c960 100644 --- a/app/Domains/Ticketing/Event/Models/Event.php +++ b/app/Domains/Ticketing/Event/Models/Event.php @@ -12,14 +12,14 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; -#[Fillable(['tenant_code', 'title', 'subtitle', 'description', 'location', 'date_text', 'published_at', 'attachment_id'])] +#[Fillable(['tenant_code', 'title', 'subtitle', 'description', 'location', 'exact_location', 'date_text', 'published_at', 'attachment_id'])] class Event extends Model { use HasFactory; protected function casts(): array { - return ['published_at' => 'datetime']; + return ['published_at' => 'datetime', 'exact_location' => 'array']; } /** @return BelongsTo */ diff --git a/app/Domains/Ticketing/Event/Requests/UpdateEventRequest.php b/app/Domains/Ticketing/Event/Requests/UpdateEventRequest.php index d1a476b..f18c1b7 100644 --- a/app/Domains/Ticketing/Event/Requests/UpdateEventRequest.php +++ b/app/Domains/Ticketing/Event/Requests/UpdateEventRequest.php @@ -19,6 +19,9 @@ class UpdateEventRequest extends FormRequest return [ 'title' => ['required', 'string', 'max:255'], 'location' => ['required', 'string', 'max:255'], + 'exact_location' => ['sometimes', 'nullable', 'array:latitude,longitude'], + 'exact_location.latitude' => ['required_with:exact_location', 'numeric', 'between:-90,90'], + 'exact_location.longitude' => ['required_with:exact_location', 'numeric', 'between:-180,180'], 'attachment_id' => ['sometimes', 'nullable', 'integer', Rule::exists('attachments', 'id')->where('type', 'image')], 'social_media' => ['sometimes', 'array'], 'social_media.*' => ['required', 'array:code,url,orden'], diff --git a/app/Domains/Ticketing/Event/Resources/EventResource.php b/app/Domains/Ticketing/Event/Resources/EventResource.php index 4f2ca77..7baf104 100644 --- a/app/Domains/Ticketing/Event/Resources/EventResource.php +++ b/app/Domains/Ticketing/Event/Resources/EventResource.php @@ -21,6 +21,7 @@ class EventResource extends JsonResource 'subtitle' => $this->subtitle, 'description' => $this->description, 'location' => $this->location, + 'exact_location' => $this->exact_location, 'date_text' => $this->date_text, 'published_at' => $this->published_at?->toIso8601String(), 'attachment_id' => $this->attachment_id, diff --git a/app/Domains/Ticketing/Event/Resources/PublicEventResource.php b/app/Domains/Ticketing/Event/Resources/PublicEventResource.php index e5a5395..ac67e9a 100644 --- a/app/Domains/Ticketing/Event/Resources/PublicEventResource.php +++ b/app/Domains/Ticketing/Event/Resources/PublicEventResource.php @@ -15,6 +15,7 @@ class PublicEventResource extends JsonResource 'subtitle' => $this->subtitle, 'description' => $this->description, 'location' => $this->location, + 'exact_location' => $this->exact_location, 'date_text' => $this->date_text, 'attachment_id' => $this->attachment_id, 'image' => $this->attachment?->getTemporaryUrl(1440), diff --git a/app/Domains/Ticketing/Event/Services/EventService.php b/app/Domains/Ticketing/Event/Services/EventService.php index 6633154..ec2b436 100644 --- a/app/Domains/Ticketing/Event/Services/EventService.php +++ b/app/Domains/Ticketing/Event/Services/EventService.php @@ -47,7 +47,7 @@ class EventService $event->update([ 'title' => $data['title'], 'location' => $data['location'], - ...array_intersect_key($data, ['attachment_id' => true]), + ...array_intersect_key($data, ['attachment_id' => true, 'exact_location' => true]), ]); $tenant->update([ ...array_intersect_key($data, array_flip([ diff --git a/app/Domains/Ticketing/Event/documentacion/README.md b/app/Domains/Ticketing/Event/documentacion/README.md index 5822002..97ac8b4 100644 --- a/app/Domains/Ticketing/Event/documentacion/README.md +++ b/app/Domains/Ticketing/Event/documentacion/README.md @@ -10,6 +10,8 @@ Administra los eventos de un tenant, sus fechas y sus redes sociales. ubicación, texto de fechas y `published_at`. Sus fechas se guardan en `event_dates` mediante `event_id`. El catálogo `social_media` define las plataformas; `event_social_media` guarda la URL y el orden de cada cuenta del evento. +`exact_location` guarda opcionalmente un objeto JSON con `latitude` (-90 a 90) +y `longitude` (-180 a 180). `location` sigue siendo la dirección legible. La migración `2026_09_18_000500_restore_events` crea un evento por cada tenant que tenía datos de evento o fechas, y migra las fechas y redes correspondientes. diff --git a/database/migrations/2026_09_18_001000_add_exact_location_to_events.php b/database/migrations/2026_09_18_001000_add_exact_location_to_events.php new file mode 100644 index 0000000..ef4ec4b --- /dev/null +++ b/database/migrations/2026_09_18_001000_add_exact_location_to_events.php @@ -0,0 +1,22 @@ +json('exact_location')->nullable()->after('location'); + }); + } + + public function down(): void + { + Schema::table('events', function (Blueprint $table): void { + $table->dropColumn('exact_location'); + }); + } +};