*/ public function toArray(Request $request): array { $socialMedia = $this->socialMedia->keyBy('code'); return [ 'id' => $this->id, 'title' => $this->title, 'subtitle' => $this->subtitle, 'description' => $this->description, 'location' => $this->location, 'date_text' => $this->date_text, 'published_at' => $this->published_at?->toIso8601String(), 'attachment_id' => $this->attachment_id, 'allow_ticket_refund' => $this->tenant->allow_ticket_refund, 'allow_ticket_total_refund' => $this->tenant->allow_ticket_total_refund, 'allow_ticket_partial_refund' => $this->tenant->allow_ticket_partial_refund, 'ticket_partial_refund_percentage' => $this->tenant->ticket_partial_refund_percentage, 'dates' => EventDateResource::collection( app(EventDateGroupingService::class)->group($this->dates) ), 'social_media' => $this->socialMedia->map(fn ($item): array => [ 'code' => $item->code, 'url' => $item->pivot->url, 'orden' => $item->pivot->orden, ])->values(), 'contact' => [ 'whatsapp_url' => $socialMedia->get('whatsapp')?->pivot->url, 'instagram_url' => $socialMedia->get('instagram')?->pivot->url, 'facebook_url' => $socialMedia->get('facebook')?->pivot->url, ], ]; } }