Handling ICAL import
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user