Add attendee count helpers and enhance Meetup API responses

-  Introduce `attendeesCount` and `mightAttendeesCount` methods in `MeetupEvent` model for cleaner attendee calculations.
- 🛠️ Refactor API responses to use attendee count helpers in `Meetup` and `MeetupEventController`.
- 🧪 Update tests to validate JSON structure with attendee-related fields (`id`, `attendees`, `might_attendees`).
This commit is contained in:
HolgerHatGarKeineNode
2026-06-15 22:45:28 +02:00
parent 0a1d177fc4
commit c3028b8260
4 changed files with 23 additions and 5 deletions
@@ -59,10 +59,13 @@ class MeetupEventController extends Controller
->get();
return $events->map(fn ($event) => [
'id' => $event->id,
'start' => $event->start->format('Y-m-d H:i'),
'location' => $event->location,
'description' => $event->description,
'link' => $event->link,
'attendees' => $event->attendeesCount(),
'might_attendees' => $event->mightAttendeesCount(),
'meetup.name' => $event->meetup->name,
'meetup.portalLink' => url()->route(
'meetups.landingpage',
@@ -202,8 +205,8 @@ class MeetupEventController extends Controller
{
return [
'status' => $meetupEvent->rsvpStatusFor($user)->value,
'attendees' => count($meetupEvent->attendees ?? []),
'might_attendees' => count($meetupEvent->might_attendees ?? []),
'attendees' => $meetupEvent->attendeesCount(),
'might_attendees' => $meetupEvent->mightAttendeesCount(),
];
}
}