Support oft parent groups
This commit is contained in:
@@ -73,12 +73,18 @@ class EventParticipantRepository {
|
||||
->first();
|
||||
}
|
||||
|
||||
public function groupByLocalGroup(Event $event, Request $request, ?string $filter = null) : array {
|
||||
/** Ob es zur Veranstaltung schon Anmeldungen gibt -- abgemeldete eingeschlossen. */
|
||||
public function existsForEvent(Event $event) : bool {
|
||||
return EventParticipant::where('event_id', $event->id)->exists();
|
||||
}
|
||||
|
||||
/** Gruppiert nach der bei der Anmeldung gewählten Gruppe (Local oder Parent Group, je nach Veranstaltung). */
|
||||
public function groupByParticipantGroup(Event $event, Request $request, ?string $filter = null) : array {
|
||||
$allParticipants = $this->getForList($event, $request);
|
||||
$participants = [];
|
||||
foreach ($allParticipants as $participant) {
|
||||
if ($filter === null || $participant['localgroup'] === $filter) {
|
||||
$participants[$participant['localgroup']][] = $participant;
|
||||
if ($filter === null || $participant['participantGroup'] === $filter) {
|
||||
$participants[$participant['participantGroup']][] = $participant;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\GlobalSetting;
|
||||
|
||||
/**
|
||||
* Zugriff auf die app-weiten Einstellungen. Im Container als `scoped` registriert -- über
|
||||
* `app(GlobalSettingRepository::class)` beziehen, dann werden die Werte nur einmal pro Request gelesen
|
||||
* (die Bezeichnungen werden je Teili-Zeile einer Liste gebraucht).
|
||||
*/
|
||||
class GlobalSettingRepository {
|
||||
/** @var array<string, string>|null */
|
||||
private ?array $values = null;
|
||||
|
||||
public function get(string $key, string $default) : string {
|
||||
$value = $this->all()[$key] ?? null;
|
||||
|
||||
return ($value === null || trim($value) === '') ? $default : $value;
|
||||
}
|
||||
|
||||
/** @param array<string, string> $values */
|
||||
public function setMany(array $values) : void {
|
||||
foreach ($values as $key => $value) {
|
||||
GlobalSetting::updateOrCreate(['key' => $key], ['value' => $value]);
|
||||
}
|
||||
|
||||
$this->values = null;
|
||||
}
|
||||
|
||||
/** @return array<string, string> */
|
||||
private function all() : array {
|
||||
return $this->values ??= GlobalSetting::pluck('value', 'key')->all();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user