*/ public function toArray(Request $request): array { $socialMedia = $this->socialMedia->keyBy('code'); return [ 'id' => $this->id, 'title' => $this->event_title, 'location' => $this->event_location, 'dates' => EventDateResource::collection($this->eventDates), '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, ], ]; } }