Handling ICAL import

This commit is contained in:
2026-04-25 16:50:32 +02:00
parent 6f8be58943
commit 1ee6b9968f
22 changed files with 510 additions and 19 deletions

View File

@@ -178,4 +178,47 @@ class EventParticipantRepository {
}
return $mailAddresses;
}
public function getMyParticipations(?int $maxEvents = null) : array {
$participations = [];
$user = auth()->user();
if ($user === null) {
return $participations;
}
$request = new \Illuminate\Http\Request();
$query = EventParticipant::where('user_id', $user->id)
->whereNull('unregistered_at')
->whereHas('event', function ($q) {
$q->where('end_date', '>=', now());
})
->with(['event'])
->join('events', 'event_participants.event_id', '=', 'events.id')
->orderBy('events.start_date', 'asc')
->select('event_participants.*');
if ($maxEvents !== null) {
$query->limit($maxEvents);
}
foreach ($query->get() as $participant) {
$participations[] = $participant->toResource()->toArray($request);
}
return $participations;
}
public function getMyParticipationByIdentifier(string $identifier) : ?EventParticipant {
$user = auth()->user();
if ($user === null) {
return null;
}
return EventParticipant::where('identifier', $identifier)
->where('tenant', app('tenant')->slug)
->where('user_id', $user->id)
->whereNull('unregistered_at')
->first();
}
}