Participant mangement
This commit is contained in:
@@ -8,9 +8,16 @@ use App\Models\EventParticipant;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class EventParticipantRepository {
|
||||
public function getForList(Event $event, Request $request) : array {
|
||||
public function getForList(Event $event, Request $request, bool $signedOffParticipants = false) : array {
|
||||
$participants = [];
|
||||
foreach ($event->participants()->orderBy('lastname')->orderBy('firstname')->get() as $participant) {
|
||||
|
||||
if (!$signedOffParticipants) {
|
||||
$allParticipants = $event->participants()->whereNull('unregistered_at');
|
||||
} else {
|
||||
$allParticipants = $event->participants()->whereNotNull('unregistered_at');
|
||||
}
|
||||
|
||||
foreach ($allParticipants->orderBy('lastname')->orderBy('firstname')->get() as $participant) {
|
||||
$participants[] = $participant->toResource()->toArray($request);
|
||||
};
|
||||
|
||||
@@ -52,6 +59,16 @@ class EventParticipantRepository {
|
||||
return $participants;
|
||||
}
|
||||
|
||||
public function getSignedOffParticipants(Event $event, Request $request) : array {
|
||||
$allParticipants = $this->getForList($event, $request, true);
|
||||
$participants = [];
|
||||
foreach ($allParticipants as $participant) {
|
||||
$participants[$participant['participationType']][] = $participant;
|
||||
}
|
||||
|
||||
return $participants;
|
||||
}
|
||||
|
||||
public function getParticipantsWithIntolerances(Event $event, Request $request) : array {
|
||||
$participants = [];
|
||||
foreach ($event->participants()->whereNotNull('intolerances')->whereNot('intolerances' , '=', '')->get() as $participant) {
|
||||
|
||||
Reference in New Issue
Block a user