Skip to content

Commit

Permalink
Merge 2f87ff5 into 147ccb5
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterbles authored Oct 18, 2023
2 parents 147ccb5 + 2f87ff5 commit 5d925ff
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions app/Services/AgendaApplicationFormService.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,46 @@ public function getRegisteredUsers(AgendaItem $agendaItem): array
{
// Eager load necessary relationships
$agendaItem->load('getApplicationForm.applicationFormRows', 'getApplicationFormResponses.getApplicationResponseUser', 'getApplicationFormResponses.getApplicationFormResponseRows.getApplicationFormRow');

// Retrieve necessary objects
$applicationForm = $agendaItem->getApplicationForm;
$applicationResponses = $agendaItem->getApplicationFormResponses;


if (is_null($applicationForm)) {
return [];

Check warning on line 24 in app/Services/AgendaApplicationFormService.php

View check run for this annotation

Codecov / codecov/patch

app/Services/AgendaApplicationFormService.php#L23-L24

Added lines #L23 - L24 were not covered by tests
}

// Map custom fields
$customfields = $applicationForm->applicationFormRows
->pluck('applicationFormRowName')
->map->text()
->all();

// Map user data
$userdata = $applicationResponses->map(function ($response) use ($agendaItem) {
$user = $response->getApplicationResponseUser;
$user["_signupId"] = $response->id;
$response->getApplicationFormResponseRows->each(function($responseRow) use (&$user) {

$response->getApplicationFormResponseRows->each(function ($responseRow) use (&$user) {

Check warning on line 38 in app/Services/AgendaApplicationFormService.php

View check run for this annotation

Codecov / codecov/patch

app/Services/AgendaApplicationFormService.php#L38

Added line #L38 was not covered by tests
$columnname = $responseRow->getApplicationFormRow->applicationFormRowName->text();
$user[$columnname] = $responseRow->value;
});

if ($agendaItem->climbing_activity) {
$user['certificate_names'] = $user->getCertificationsAbbreviations();
}
return $user;
})->all();

// Build the final array to return
return [
"agendaitem" => $agendaItem->agendaItemTitle->text(),
"agendaId" => $agendaItem->id,
"userdata" => $userdata,
"customfields" => $customfields
"agendaitem" => $agendaItem->agendaItemTitle->text(),
"agendaId" => $agendaItem->id,
"userdata" => $userdata,
"customfields" => $customfields,

Check warning on line 54 in app/Services/AgendaApplicationFormService.php

View check run for this annotation

Codecov / codecov/patch

app/Services/AgendaApplicationFormService.php#L51-L54

Added lines #L51 - L54 were not covered by tests
];
}


/**
* @param AgendaItem $agendaItem
* @return array
Expand All @@ -69,15 +72,14 @@ public function getRegisteredUserIds(AgendaItem $agendaItem): array

return $userdataIds;
}


/**
* @param AgendaItem $agendaItem
* @return Collection
*/
public function getExportData(AgendaItem $agendaItem): Collection
{
$users = $this->getRegisteredUsers($agendaItem);
$users = $this->getRegisteredUsers($agendaItem);

Check warning on line 82 in app/Services/AgendaApplicationFormService.php

View check run for this annotation

Codecov / codecov/patch

app/Services/AgendaApplicationFormService.php#L82

Added line #L82 was not covered by tests
$selectedElements = array(
"firstname",
"preposition",
Expand All @@ -86,7 +88,7 @@ public function getExportData(AgendaItem $agendaItem): Collection
"houseNumber",
"city",
"email",
"phonenumber"
"phonenumber",

Check warning on line 91 in app/Services/AgendaApplicationFormService.php

View check run for this annotation

Codecov / codecov/patch

app/Services/AgendaApplicationFormService.php#L91

Added line #L91 was not covered by tests
);
$selectedElements = array_merge($selectedElements, $users["customfields"]);

Expand All @@ -102,4 +104,4 @@ public function getExportData(AgendaItem $agendaItem): Collection
return new Collection($activeUsers);
}

}
}

0 comments on commit 5d925ff

Please sign in to comment.