Compare commits
312 Commits
Author | SHA1 | Date |
---|---|---|
|
dafda4883d | |
|
e6526ee326 | |
|
44e8da9a37 | |
|
4e43609619 | |
|
32246e534e | |
|
4b50c85fd6 | |
|
e5ecd0a2c0 | |
|
e06f924304 | |
|
6463997f8f | |
|
247a89ae77 | |
|
6c3c8b5703 | |
|
5fe1004871 | |
|
4f9bfa0f75 | |
|
a27e86ffcc | |
|
c8e268d91b | |
|
10b71f7a36 | |
|
144af1bf71 | |
|
17808c6eb1 | |
|
427f45373e | |
|
a1981c7dec | |
|
4497084ae6 | |
|
f2090aa9d0 | |
|
6b7de1446f | |
|
f8d2be9df5 | |
|
722237f486 | |
|
51af9d427e | |
|
b0fd584397 | |
|
aab004f1f1 | |
|
79d92a6567 | |
|
a136085d2b | |
|
67fe88c9b4 | |
|
36932f8417 | |
|
3f92a48f29 | |
|
e396714d31 | |
|
af13bb1cde | |
|
bd86e65c8c | |
|
8ea566c400 | |
|
d74fcab024 | |
|
392a34b5c7 | |
|
04ddcdb0d5 | |
|
bfdb591baf | |
|
890201817f | |
|
5a2707ccac | |
|
b2153e647d | |
|
392e385682 | |
|
88bb1091a9 | |
|
e2d489d83f | |
|
dce7c26b7e | |
|
4b38296687 | |
|
634a13b4dd | |
|
0bb1d2b309 | |
|
d0bd5bb0de | |
|
b86fe9634f | |
|
752a5d7c29 | |
|
9f0516ad55 | |
|
2e1df9791d | |
|
ce976c1108 | |
|
4d25f5e56d | |
|
21cebfc04a | |
|
d53a6d23d2 | |
|
ccef61352d | |
|
5be7987d80 | |
|
ac592920e7 | |
|
68651b6c16 | |
|
cff62ebc1d | |
|
c3ecb9dc63 | |
|
ab442dff9b | |
|
88e020ac4e | |
|
d7361b6713 | |
|
4538ec8ca8 | |
|
6032b9c289 | |
|
6da6453b5d | |
|
66b6a549c3 | |
|
878de3f566 | |
|
aa55b56df7 | |
|
31c582e81d | |
|
adf9341dd7 | |
|
9853d4e82e | |
|
4698c808f8 | |
|
ea2eb08052 | |
|
09f401055a | |
|
2c786b62ce | |
|
4cd18e9b3c | |
|
9d41cdb010 | |
|
e429d7de76 | |
|
52a6491488 | |
|
9628ba34d2 | |
|
5361c3930f | |
|
e97d39abd7 | |
|
419b4227eb | |
|
63b57f3da7 | |
|
0ea3f4adce | |
|
363c4360b8 | |
|
3182dc7edd | |
|
7346c2da47 | |
|
95a466ff22 | |
|
e047b9a4f2 | |
|
0311787eec | |
|
fba42fa1d8 | |
|
fe50cf129f | |
|
27f805700e | |
|
f33a23ecc3 | |
|
103e13966f | |
|
b2117cdecf | |
|
177b661d50 | |
|
1c0a2361d6 | |
|
4ed6375202 | |
|
f9c4e32ba2 | |
|
1780e3bce8 | |
|
bf4cfdf7fd | |
|
057002b8e8 | |
|
99731fd08f | |
|
919041d2cf | |
|
47b5abc0f1 | |
|
ea79290435 | |
|
4f21dfceee | |
|
196b81a82d | |
|
83d721c1ca | |
|
027a159a1c | |
|
da8dd12dad | |
|
a482e16739 | |
|
010ad80793 | |
|
741a4a24b7 | |
|
4ecf2f4483 | |
|
fc2b3d6885 | |
|
d07a9a8372 | |
|
64511479ef | |
|
25cf073fc7 | |
|
bf09ed8e0f | |
|
5a48c983cd | |
|
be771af35e | |
|
629797c03f | |
|
7206c88998 | |
|
31f398f7d4 | |
|
22aa303311 | |
|
f2fb583797 | |
|
2e010aece1 | |
|
793f916581 | |
|
37c9021e76 | |
|
2e0b42bfbd | |
|
3c7cd1173a | |
|
0c14ebb229 | |
|
0679a09d26 | |
|
2dd0c3d2a0 | |
|
21964e9665 | |
|
5afe8613e1 | |
|
c047f8da63 | |
|
9097f0bbd9 | |
|
3f44fbe5b0 | |
|
8e1f7869e2 | |
|
abf4158256 | |
|
f2d59e4535 | |
|
a75b4a7808 | |
|
ecf3cc998c | |
|
7202cd60f5 | |
|
9d5c71adcd | |
|
eb00d928fc | |
|
6683990755 | |
|
2a5f4832e1 | |
|
719b1920c9 | |
|
3260202465 | |
|
9b995641b6 | |
|
2d5921fe1d | |
|
efa9eeccbe | |
|
b33072ad20 | |
|
2e77823c3a | |
|
9a5d9ae30e | |
|
d607c8beac | |
|
1a86ea7ea5 | |
|
a157f2b656 | |
|
e3c7dad51e | |
|
749e3dcd7c | |
|
4417008d22 | |
|
b38591b87c | |
|
17e4fe5f82 | |
|
b2f3e4f1fd | |
|
376c1ceb9b | |
|
056b8f9ed6 | |
|
011e414848 | |
|
5e64797277 | |
|
2e8dc96665 | |
|
b1dcdeb579 | |
|
a456cc1889 | |
|
784b49c3dd | |
|
c3a0381a0a | |
|
101ac7402a | |
|
2c38488962 | |
|
8a26276e28 | |
|
4651a4cb96 | |
|
688e10e230 | |
|
267da38c6b | |
|
499c61afff | |
|
02531938b3 | |
|
1c53e81f1a | |
|
98712093b2 | |
|
a32ef33113 | |
|
088ea4f0a2 | |
|
4ac89da124 | |
|
286ceea0d4 | |
|
52ac5937a4 | |
|
4690e86bbf | |
|
1a4a7c3652 | |
|
b05c5025c0 | |
|
acf7b94094 | |
|
57b1efb065 | |
|
3e563f8390 | |
|
0a5590d533 | |
|
10deaf15a1 | |
|
ae447a7a60 | |
|
baea21807a | |
|
58426c5537 | |
|
84cd13c085 | |
|
b8d2b37057 | |
|
44eb3719b9 | |
|
c65a208e34 | |
|
95a8d4d689 | |
|
e1e8669beb | |
|
a3ecfa756d | |
|
70e085a49e | |
|
1178b011e0 | |
|
6a91e857d2 | |
|
82baf67a73 | |
|
36466420f6 | |
|
54c37fccd1 | |
|
d03f036a2b | |
|
75d11f9860 | |
|
da4d553ea6 | |
|
5bad88c5f4 | |
|
75dc0d9769 | |
|
9fc8548504 | |
|
c990ce3171 | |
|
e7f63d19e5 | |
|
f549b31862 | |
|
1f4efb22d3 | |
|
3e725d9842 | |
|
16d3bc51a3 | |
|
0467f24ff6 | |
|
ed1a8f30bc | |
|
e5066af192 | |
|
31afa2e418 | |
|
a897690e7a | |
|
24ed5d4ab9 | |
|
e807aff3e6 | |
|
096224fe98 | |
|
646ce647da | |
|
f858716e57 | |
|
1521aba1f8 | |
|
664b88564d | |
|
d30a2336cf | |
|
a5f1c90003 | |
|
c3908b714b | |
|
2f1e02151f | |
|
eaf014b7c7 | |
|
94d34d1afa | |
|
9b700be889 | |
|
e1ec6ad9df | |
|
aaa236fcd5 | |
|
4d74e53fc2 | |
|
b8d389bdb9 | |
|
3a4c99f154 | |
|
fca7fc463e | |
|
767df11e4f | |
|
295d85f4f8 | |
|
42ccd32740 | |
|
bbcf2fd768 | |
|
b335c20777 | |
|
c63c8316b5 | |
|
2e6c27b8f1 | |
|
1cf8d34b78 | |
|
e3b52bf901 | |
|
76e7b06630 | |
|
21def11ae9 | |
|
565b1ffbce | |
|
ef70203c8a | |
|
b3a29c706c | |
|
298140e387 | |
|
151477dbdd | |
|
a01e8adf8a | |
|
547c9edfd5 | |
|
6e09e2ec0d | |
|
9d37ebefc5 | |
|
11b1e6a198 | |
|
5008244de2 | |
|
8b3b3de9a8 | |
|
d9adb526ce | |
|
daf6e87814 | |
|
2056e1ad6b | |
|
a4eba23bff | |
|
ad8cd58b4f | |
|
3a4908f505 | |
|
291eec3849 | |
|
0e0f23c17e | |
|
6d204b948e | |
|
977e427abb | |
|
46e070a029 | |
|
84e05fbc52 | |
|
343b0d418d | |
|
fe258198f4 | |
|
8317fdca90 | |
|
32ec479975 | |
|
ac45e0c8fa | |
|
6f1ab73bae | |
|
c95658ae65 | |
|
d64ea85be6 | |
|
22157b5d50 | |
|
107b616bc1 | |
|
d7cc80afe9 | |
|
db6248999a | |
|
9c568176ce | |
|
d56cb253a9 | |
|
5fcee5f284 | |
|
b01ff9a677 |
|
@ -1,13 +1,14 @@
|
|||
FROM php:8.1.6-fpm as php
|
||||
FROM php:8.3.11-fpm AS php
|
||||
WORKDIR /app
|
||||
RUN ls /app
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y rsync libcurl3-dev apt-utils zlib1g-dev libpng-dev libicu-dev libonig-dev unzip poppler-utils libpng-dev libjpeg-dev default-mysql-client
|
||||
RUN apt-get install -y rsync libcurl3-dev apt-utils zlib1g-dev libpng-dev libicu-dev libonig-dev unzip poppler-utils libpng-dev libjpeg-dev default-mysql-client libzip-dev imagemagick libmagickwand-dev
|
||||
RUN apt-get install -y --no-install-recommends texlive-base texlive-latex-base texlive-pictures texlive-latex-extra texlive-lang-german texlive-plain-generic texlive-fonts-recommended texlive-fonts-extra texlive-extra-utils
|
||||
RUN docker-php-ext-install pdo_mysql curl gd exif intl mbstring pcntl
|
||||
RUN docker-php-ext-install pdo_mysql curl exif intl mbstring pcntl zip
|
||||
RUN pecl install redis && docker-php-ext-enable redis
|
||||
RUN pecl install imagick && docker-php-ext-enable imagick
|
||||
RUN docker-php-ext-configure gd --with-jpeg
|
||||
RUN docker-php-ext-enable gd
|
||||
RUN docker-php-ext-install gd
|
||||
RUN usermod -s /bin/bash www-data
|
||||
RUN echo 'memory_limit = 2G' >> /usr/local/etc/php/conf.d/99-custom-php-memlimit.ini
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
docker buildx build -f .docker/base.Dockerfile .
|
||||
docker image tag sha256:... zoomyboy/adrema-base
|
||||
docker push zoomyboy/adrema-base
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
FROM composer:2.2.7 as composer
|
||||
FROM composer:2.7.9 AS composer
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
RUN composer install --ignore-platform-reqs --no-dev
|
||||
RUN php artisan telescope:publish
|
||||
RUN php artisan horizon:publish
|
||||
|
||||
FROM node:20.15.0-slim as node
|
||||
FROM node:20.15.0-slim AS node
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
RUN npm install && npm run prod && npm run img && rm -R node_modules
|
||||
|
||||
FROM nginx:1.21.6-alpine as nginx
|
||||
FROM nginx:1.21.6-alpine AS nginx
|
||||
WORKDIR /app
|
||||
COPY --from=node /app /app
|
||||
COPY --from=composer /app/public/vendor /app/public/vendor
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
FROM composer:2.2.7 as composer
|
||||
FROM composer:2.7.9 AS composer
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
RUN composer install --ignore-platform-reqs --no-dev
|
||||
|
||||
FROM node:20.15.0-slim as node
|
||||
FROM node:20.15.0-slim AS node
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
RUN npm install && npm run prod && npm run img && rm -R node_modules
|
||||
|
||||
FROM zoomyboy/adrema-base:latest as php
|
||||
FROM zoomyboy/adrema-base:latest AS php
|
||||
COPY --chown=www-data:www-data . /app
|
||||
COPY --chown=www-data:www-data --from=node /app/public /app/public
|
||||
COPY --chown=www-data:www-data --from=composer /app/vendor /app/vendor
|
||||
|
|
|
@ -12,7 +12,7 @@ steps:
|
|||
- git submodule update --init --recursive
|
||||
|
||||
- name: composer_dev
|
||||
image: composer:2.2.7
|
||||
image: composer:2.7.9
|
||||
commands:
|
||||
- composer install --ignore-platform-reqs --dev
|
||||
|
||||
|
@ -39,6 +39,7 @@ steps:
|
|||
- name: tests
|
||||
image: zoomyboy/adrema-base:latest
|
||||
commands:
|
||||
- touch .env
|
||||
- php artisan migrate
|
||||
- php artisan test
|
||||
- rm -f .env
|
||||
|
@ -102,7 +103,7 @@ steps:
|
|||
event: tag
|
||||
|
||||
- name: deploy
|
||||
image: php:8.1.6
|
||||
image: zoomyboy/adrema-base:latest
|
||||
environment:
|
||||
SSH_KEY:
|
||||
from_secret: deploy_private_key
|
||||
|
@ -135,7 +136,7 @@ steps:
|
|||
event: push
|
||||
|
||||
- name: composer_no_dev
|
||||
image: composer:2.2.7
|
||||
image: composer:2.7.9
|
||||
commands:
|
||||
- composer install --ignore-platform-reqs --no-dev
|
||||
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es2021": true
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:vue/vue3-recommended",
|
||||
"prettier"
|
||||
],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": "latest",
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": [
|
||||
"vue"
|
||||
],
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"*.vue"
|
||||
],
|
||||
"rules": {
|
||||
"vue/multi-word-component-names": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -40,3 +40,4 @@ Homestead.json
|
|||
/public/sprite.svg
|
||||
/.php-cs-fixer.cache
|
||||
/groups.sql
|
||||
/.phpunit.cache
|
||||
|
|
111
CHANGELOG.md
111
CHANGELOG.md
|
@ -1,5 +1,116 @@
|
|||
# Letzte Änderungen
|
||||
|
||||
### 1.12.19
|
||||
|
||||
- Zuschusslisten können nun aus Veranstaltungs-Daten erstellt werden
|
||||
- Veranstaltungs-Übersicht zeigt nun Tags an
|
||||
|
||||
### 1.12.18
|
||||
|
||||
- Fix: Initialisierung klappt nun auch, wenn Mitgliedsnummer mit einer 0 beginnt
|
||||
|
||||
### 1.12.17
|
||||
|
||||
- Fix: Mitgliedschaften werden beim Sammel-Speichern nicht mehr doppelt angelegt
|
||||
|
||||
### 1.12.16
|
||||
|
||||
- Mitgliedschaften können nun bei Mitgliedschaften-Übersicht gelöscht werden
|
||||
|
||||
### 1.12.15
|
||||
|
||||
- Bestätigung wird eingeblendet beim Kopieren eines Events
|
||||
|
||||
### 1.12.14
|
||||
|
||||
- Bilder werden nun mitkopiert beim Kopieren eines Events
|
||||
|
||||
### 1.12.13
|
||||
|
||||
- Kopieren von bestehenden Veranstaltungen
|
||||
- Präventions-Erinnerung automatisch versenden
|
||||
|
||||
### 1.12.11
|
||||
|
||||
- Fix: Bank Account mit abrufen wenn Mitglied editiert wird
|
||||
|
||||
### 1.12.7
|
||||
|
||||
- Fix: Synchronisation von allen Mitgliedern bei Mail-Verteilern - nicht nur den ersten 20
|
||||
|
||||
### 1.12.6
|
||||
|
||||
- Fix: Beiträge von Familienmitgliedern splitten
|
||||
|
||||
### 1.12.5
|
||||
|
||||
- Fix: Synchronisieren von bestehenden Beiträgen aus NaMi
|
||||
|
||||
### 1.12.4
|
||||
|
||||
- Filter Mitglieder nach Verhaltenskodex
|
||||
|
||||
### 1.12.3
|
||||
|
||||
- Volltextsuche für Rechnungen
|
||||
|
||||
### 1.12.2
|
||||
|
||||
- Zuschussliste Gallier
|
||||
|
||||
### 1.12.1
|
||||
|
||||
- In Teilnehmer-Liste von Veranstaltungen kann nun sortiert und gefiltert werden.
|
||||
- Formulare: Feld Registrierung von / bis
|
||||
|
||||
### 1.11.5
|
||||
|
||||
- Fix: Synchronisation von NaMi-Mitgliedern
|
||||
|
||||
### 1.11.4
|
||||
|
||||
- Fix: Nicht an Präventions-Unterlagen für vergangene Veranstaltungen erinnern
|
||||
|
||||
### 1.11.1
|
||||
|
||||
- Es kann nun auch das Feld "Datenweiterverwendung" über Adrema gepflegt werden.
|
||||
|
||||
### 1.10.20
|
||||
|
||||
- Fixed: Bei Textfeldern wird nun die Einleitung dargestellt
|
||||
|
||||
### 1.10.19
|
||||
|
||||
- Fixed: Erweiterte Führungszeugnisse und Präventionsschulungen nur für aktive Mitgliedschaften auf Dashboard anzeigen
|
||||
|
||||
### 1.10.18
|
||||
|
||||
- Fixed: All Gruppen als Option anbieten bei Bedingungen
|
||||
|
||||
### 1.10.17
|
||||
|
||||
- Es können nun auch Bedingungen für Felder vom Typ Gruppierung definiert werden
|
||||
|
||||
### 1.10.16
|
||||
|
||||
- Rechnungen und Erinnerungen werden nun automatisch täglich um 10 Uhr verschickt
|
||||
- Es kann eingestellt werden, nach wie vielen Wochen an Rechnungen erinnert werden soll (Standard: 12)
|
||||
- Name und Profilbild des angemeldeten Benutzers wird nun oben rechts angezeigt
|
||||
|
||||
### 1.10.15
|
||||
|
||||
- "Für Mitglieder zusätzlich abfragen" kann nun im Formular auch gesetzt werden, wenn ein NaMi Feld ausgewählt ist.
|
||||
|
||||
### 1.10.14
|
||||
|
||||
- Fixed: Ist eine Präventionsschulung älter als 5 Jahre, so ist nur eine Auffrischungs-Schulung erforderlich
|
||||
|
||||
### 1.10.13
|
||||
|
||||
- Bei Veranstaltungs-Übersicht alle Veranstaltungen anzeigen
|
||||
- Download von Teilnehmern als Tabellen-Dokument
|
||||
- Spalte "Prävention" bei TN-Liste eingefügt für benötigte Unterlagen
|
||||
|
||||
### 1.10.11
|
||||
|
||||
- Bei Prävention auch an Verhaltenskodex erinnern
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@servers(['docker' => ['stammsilva@zoomyboy.de', 'stammgallier@stamm-gallier.de', 'dpsg-lennep@zoomyboy.de', 'dpsgbergischland@zoomyboy.de', 'dpsg-koeln@dpsg-koeln.de']])
|
||||
@servers(['docker' => ['stamm-silva@zoomyboy.de', 'stammgallier@stamm-gallier.de', 'dpsg-lennep@zoomyboy.de', 'dpsgbergischland@zoomyboy.de', 'dpsg-koeln@dpsg-koeln.de']])
|
||||
|
||||
@task('deploy', ['on' => 'docker'])
|
||||
cd $ADREMA_PATH
|
||||
|
|
25
README.md
25
README.md
|
@ -32,16 +32,16 @@ Außerdem ist AdReMa auch problemlos auf Handys und Tablets bedienbar ("mobiles
|
|||
|
||||
## Installation des Produktivsystems
|
||||
|
||||
1. Herunterladen der Beispiel Docker-Compose
|
||||
1. Verschieben der Docker-Compose
|
||||
|
||||
```cmd
|
||||
curl https://git.zoomyboy.de/silva/adrema/raw/branch/master/docker-compose.prod.yml -o docker-compose.yml
|
||||
mv docker-compose.prod.yml docker-compose.yml
|
||||
```
|
||||
|
||||
2. Herunterladen der Beispiel Environmentvariablen-Datei
|
||||
2. Anwenden der Beispiel Environmentvariablen-Datei
|
||||
|
||||
```cmd
|
||||
curl https://git.zoomyboy.de/silva/adrema/raw/branch/master/.app.env.example -o .app.env
|
||||
mv .app.env.example .app.env
|
||||
```
|
||||
|
||||
3. In der `.app.env` notwendige Einstellungen vornehmen:
|
||||
|
@ -50,7 +50,8 @@ Außerdem ist AdReMa auch problemlos auf Handys und Tablets bedienbar ("mobiles
|
|||
- Mail-Server Einstellungen `MAIL_PORT`, `MAIL_HOST`, `MAIL_USERNAME`, `MAIL_PASSWORD` und `MAIL_ENCRYPTION` anpassen
|
||||
- `MAIL_FROM_NAME`: Der Name, der als Absender von E-Mails gesetzt wird (z.B. `Stamm Bipi Service`)
|
||||
- `MAIL_FROM_ADDRESS`: Die dazu gehörige E-Mail-Adresse, die natürlich für antworten erreichbar sein sollte (z.B. `vorstand@stamm-bipi.de`)
|
||||
- `DB_PASSWORD` und `MYSQL_PASSWORD`: Mit dem selben sicheren Passwort für die Datenbank versehen
|
||||
- `DB_PASSWORD` und `MYSQL_PASSWORD`: Mit dem selben neu erstellten, sicheren Passwort für die Datenbank versehen
|
||||
- `MEILI_MASTER_KEY` Mit einem neu erstellten, sicheren Passwort versehen
|
||||
- `USER_EMAIL` und `USER_PASSWORD`: Einstellen des standard Adrema Logins
|
||||
|
||||
4. Container zur Gennerierung des App-Key starten
|
||||
|
@ -99,28 +100,22 @@ Bei dem Setup wird im Daten-Verzeichniss ein Ordner `./data/setup` angelegt. Hie
|
|||
git clone https://git.zoomyboy.de/silva/adrema.git
|
||||
```
|
||||
|
||||
2. Kopieren der Beispiel Docker-Compose für das Entwickeln und nach Wünschen anpassen
|
||||
|
||||
```cmd
|
||||
cp docker-compose.dev.yml docker-compose.yml
|
||||
```
|
||||
|
||||
3. Kopieren der Beispiel Environmentvariablen-Datei
|
||||
2. Kopieren der Beispiel Environmentvariablen-Datei
|
||||
|
||||
```cmd
|
||||
cp .app.env.example .app.env
|
||||
```
|
||||
|
||||
4. Submodule aktuallisieren
|
||||
3. Submodule aktuallisieren
|
||||
|
||||
```cmd
|
||||
git submodule update --init
|
||||
```
|
||||
|
||||
5. Container erstellen
|
||||
4. Container erstellen
|
||||
|
||||
```cmd
|
||||
docker compose build
|
||||
```
|
||||
|
||||
6. Mit Schritt 3 und den folgenden der [Installation des Produktivsystems](#installation-des-produktivsystems) fortfahren
|
||||
5. Mit Schritt 3 und den folgenden der [Installation des Produktivsystems](#installation-des-produktivsystems) fortfahren
|
||||
|
|
|
@ -22,7 +22,7 @@ class InsertMemberAction
|
|||
{
|
||||
$region = Region::firstWhere('nami_id', $member->regionId ?: -1);
|
||||
|
||||
return Member::updateOrCreate(['nami_id' => $member->id], [
|
||||
$payload = [
|
||||
'firstname' => $member->firstname,
|
||||
'lastname' => $member->lastname,
|
||||
'joined_at' => $member->joinedAt,
|
||||
|
@ -50,7 +50,27 @@ class InsertMemberAction
|
|||
'nationality_id' => Nationality::where('nami_id', $member->nationalityId)->firstOrFail()->id,
|
||||
'mitgliedsnr' => $member->memberId,
|
||||
'version' => $member->version,
|
||||
]);
|
||||
'keepdata' => $member->keepdata,
|
||||
];
|
||||
|
||||
// Dont update subscription if fee id of existing member's subscription is already the same
|
||||
if ($existing = Member::nami($member->id)) {
|
||||
if ($existing->subscription && $existing->subscription->fee->nami_id === $member->feeId) {
|
||||
$payload['subscription_id'] = $existing->subscription->id;
|
||||
}
|
||||
}
|
||||
|
||||
return tap(Member::updateOrCreate(['nami_id' => $member->id], $payload), function ($insertedMember) use ($member) {
|
||||
$insertedMember->bankAccount->update([
|
||||
'iban' => $member->bankAccount->iban,
|
||||
'bic' => $member->bankAccount->bic,
|
||||
'blz' => $member->bankAccount->blz,
|
||||
'account_number' => $member->bankAccount->accountNumber,
|
||||
'person' => $member->bankAccount->person,
|
||||
'bank_name' => $member->bankAccount->bankName,
|
||||
'nami_id' => $member->bankAccount->id,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
public function getSubscription(NamiMember $member): ?Subscription
|
||||
|
|
|
@ -4,12 +4,14 @@ namespace App;
|
|||
|
||||
use App\Nami\HasNamiField;
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Database\Factories\ActivityFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Activity extends Model
|
||||
{
|
||||
/** @use HasFactory<ActivityFactory> */
|
||||
use HasFactory;
|
||||
use HasNamiField;
|
||||
use Sluggable;
|
||||
|
@ -32,7 +34,7 @@ class Activity extends Model
|
|||
}
|
||||
|
||||
/**
|
||||
* @return BelongsToMany<Subactivity>
|
||||
* @return BelongsToMany<Subactivity, $this>
|
||||
*/
|
||||
public function subactivities(): BelongsToMany
|
||||
{
|
||||
|
|
|
@ -54,6 +54,7 @@ class ActivityResource extends JsonResource
|
|||
'index' => route('activity.index'),
|
||||
'create' => route('activity.create'),
|
||||
'membership_masslist' => route('membership.masslist.index'),
|
||||
'membership_index' => route('membership.index'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
|
@ -2,11 +2,13 @@
|
|||
|
||||
namespace App;
|
||||
|
||||
use Database\Factories\ConfessionFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Confession extends Model
|
||||
{
|
||||
/** @use HasFactory<ConfessionFactory> */
|
||||
use HasFactory;
|
||||
|
||||
public $fillable = ['name', 'nami_id', 'is_null'];
|
||||
|
|
|
@ -6,6 +6,7 @@ use App\Actions\DbMaintainAction;
|
|||
use App\Form\Actions\PreventionRememberAction;
|
||||
use App\Initialize\InitializeMembers;
|
||||
use App\Invoice\Actions\InvoiceSendAction;
|
||||
use App\Prevention\Actions\YearlyRememberAction;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
|
@ -21,6 +22,7 @@ class Kernel extends ConsoleKernel
|
|||
InitializeMembers::class,
|
||||
DbMaintainAction::class,
|
||||
PreventionRememberAction::class,
|
||||
YearlyRememberAction::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -33,6 +35,8 @@ class Kernel extends ConsoleKernel
|
|||
$schedule->command(DbMaintainAction::class)->daily();
|
||||
$schedule->command(InitializeMembers::class)->dailyAt('03:00');
|
||||
$schedule->command(PreventionRememberAction::class)->dailyAt('11:00');
|
||||
$schedule->command(InvoiceSendAction::class)->dailyAt('10:00');
|
||||
$schedule->command(YearlyRememberAction::class)->dailyAt('09:00');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
namespace App\Contribution\Actions;
|
||||
|
||||
use App\Contribution\Contracts\HasContributionData;
|
||||
use App\Contribution\ContributionFactory;
|
||||
use App\Contribution\Documents\ContributionDocument;
|
||||
use App\Contribution\Requests\GenerateRequest;
|
||||
use App\Rules\JsonBase64Rule;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
use Zoomyboy\Tex\BaseCompiler;
|
||||
use Zoomyboy\Tex\Tex;
|
||||
|
@ -15,23 +15,19 @@ class GenerateAction
|
|||
{
|
||||
use AsAction;
|
||||
|
||||
/**
|
||||
* @param class-string<ContributionDocument> $document
|
||||
* @param array<string, mixed> $payload
|
||||
*/
|
||||
public function handle(string $document, array $payload): BaseCompiler
|
||||
public function handle(HasContributionData $request): BaseCompiler
|
||||
{
|
||||
return Tex::compile($document::fromRequest($payload));
|
||||
return Tex::compile($request->type()::fromPayload($request));
|
||||
}
|
||||
|
||||
public function asController(ActionRequest $request): BaseCompiler
|
||||
public function asController(GenerateRequest $request): BaseCompiler|JsonResponse
|
||||
{
|
||||
$payload = $this->payload($request);
|
||||
$type = data_get($payload, 'type');
|
||||
ValidateAction::validateType($type);
|
||||
Validator::make($payload, app(ContributionFactory::class)->rules($type))->validate();
|
||||
app(ContributionFactory::class)->validateType($request);
|
||||
$request->validateContribution();
|
||||
|
||||
return $this->handle($type, $payload);
|
||||
return $request->input('validate')
|
||||
? response()->json([])
|
||||
: $this->handle($request);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,12 +39,4 @@ class GenerateAction
|
|||
'payload' => [new JsonBase64Rule()],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
private function payload(ActionRequest $request): array
|
||||
{
|
||||
return json_decode(rawurldecode(base64_decode($request->input('payload', ''))), true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
namespace App\Contribution\Actions;
|
||||
|
||||
use App\Contribution\Documents\ContributionDocument;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use App\Contribution\Contracts\HasContributionData;
|
||||
use App\Contribution\ContributionFactory;
|
||||
use App\Contribution\Requests\GenerateApiRequest;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
use Zoomyboy\Tex\BaseCompiler;
|
||||
use Zoomyboy\Tex\Tex;
|
||||
|
@ -13,26 +14,17 @@ class GenerateApiAction
|
|||
use AsAction;
|
||||
|
||||
/**
|
||||
* @param class-string<ContributionDocument> $document
|
||||
* @param array<string, mixed> $payload
|
||||
* @todo merge this with GenerateAction
|
||||
*/
|
||||
public function handle(string $document, array $payload): BaseCompiler
|
||||
public function handle(HasContributionData $request): BaseCompiler
|
||||
{
|
||||
return Tex::compile($document::fromApiRequest($payload));
|
||||
return Tex::compile($request->type()::fromPayload($request));
|
||||
}
|
||||
|
||||
public function asController(ActionRequest $request): BaseCompiler
|
||||
public function asController(GenerateApiRequest $request): BaseCompiler
|
||||
{
|
||||
ValidateAction::validateType($request->input('type'));
|
||||
app(ContributionFactory::class)->validateType($request);
|
||||
|
||||
return $this->handle($request->input('type'), $request->input());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [];
|
||||
return $this->handle($request);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contribution\Actions;
|
||||
|
||||
use App\Contribution\ContributionFactory;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class ValidateAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
public function asController(): JsonResponse
|
||||
{
|
||||
return response()->json(['valid' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return app(ContributionFactory::class)->rules(request()->type);
|
||||
}
|
||||
|
||||
public function prepareForValidation(ActionRequest $request): void
|
||||
{
|
||||
static::validateType($request->input('type'));
|
||||
}
|
||||
|
||||
public static function validateType(?string $type = null): void
|
||||
{
|
||||
Validator::make(['type' => $type], app(ContributionFactory::class)->typeRule())->validate();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contribution\Contracts;
|
||||
|
||||
use App\Contribution\Data\MemberData;
|
||||
use Carbon\Carbon;
|
||||
use App\Contribution\Documents\ContributionDocument;
|
||||
use App\Country;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
interface HasContributionData {
|
||||
|
||||
public function dateFrom(): Carbon;
|
||||
public function dateUntil(): Carbon;
|
||||
public function zipLocation(): string;
|
||||
public function eventName(): string;
|
||||
/**
|
||||
* @return class-string<ContributionDocument>
|
||||
*/
|
||||
public function type(): string;
|
||||
|
||||
/**
|
||||
* @return Collection<int, MemberData>
|
||||
*/
|
||||
public function members(): Collection;
|
||||
|
||||
public function country(): ?Country;
|
||||
|
||||
public function validateContribution(): void;
|
||||
}
|
|
@ -2,13 +2,16 @@
|
|||
|
||||
namespace App\Contribution;
|
||||
|
||||
use App\Contribution\Contracts\HasContributionData;
|
||||
use App\Contribution\Documents\BdkjHesse;
|
||||
use App\Contribution\Documents\ContributionDocument;
|
||||
use App\Contribution\Documents\RdpNrwDocument;
|
||||
use App\Contribution\Documents\CityRemscheidDocument;
|
||||
use App\Contribution\Documents\CitySolingenDocument;
|
||||
use App\Contribution\Documents\CityFrankfurtMainDocument;
|
||||
use App\Contribution\Documents\WuppertalDocument;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class ContributionFactory
|
||||
|
@ -22,16 +25,17 @@ class ContributionFactory
|
|||
CityRemscheidDocument::class,
|
||||
CityFrankfurtMainDocument::class,
|
||||
BdkjHesse::class,
|
||||
WuppertalDocument::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* @return Collection<int, array{title: string, class: class-string<ContributionDocument>}>
|
||||
* @return Collection<int, array{name: string, id: class-string<ContributionDocument>}>
|
||||
*/
|
||||
public function compilerSelect(): Collection
|
||||
{
|
||||
return collect($this->documents)->map(fn ($document) => [
|
||||
'title' => $document::getName(),
|
||||
'class' => $document,
|
||||
'name' => $document::getName(),
|
||||
'id' => $document,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -57,4 +61,9 @@ class ContributionFactory
|
|||
...$type::rules(),
|
||||
];
|
||||
}
|
||||
|
||||
public function validateType(HasContributionData $request): void {
|
||||
Validator::make(['type' => $request->type()], $this->typeRule())->validate();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class MemberData extends Data
|
|||
*/
|
||||
public static function fromModels(array $ids): Collection
|
||||
{
|
||||
return Member::whereIn('id', $ids)->orderByRaw('lastname, firstname')->get()->map(fn ($member) => self::withoutMagicalCreationFrom([
|
||||
return Member::whereIn('id', $ids)->orderByRaw('lastname, firstname')->get()->map(fn ($member) => self::factory()->withoutMagicalCreation()->from([
|
||||
...$member->toArray(),
|
||||
'birthday' => $member->birthday->toAtomString(),
|
||||
'isLeader' => $member->isLeader(),
|
||||
|
@ -44,41 +44,51 @@ class MemberData extends Data
|
|||
*/
|
||||
public static function fromApi(array $data): Collection
|
||||
{
|
||||
return collect($data)->map(fn ($member) => self::withoutMagicalCreationFrom([
|
||||
return collect($data)->map(fn ($member) => self::factory()->withoutMagicalCreation()->from([
|
||||
...$member,
|
||||
'birthday' => Carbon::parse($member['birthday'])->toAtomString(),
|
||||
'gender' => Gender::fromString($member['gender']),
|
||||
'gender' => $member['gender'] ? Gender::fromString($member['gender']) : null,
|
||||
'isLeader' => $member['is_leader'],
|
||||
]));
|
||||
}
|
||||
|
||||
public function fullname(): string
|
||||
{
|
||||
return $this->firstname.' '.$this->lastname;
|
||||
return $this->firstname . ' ' . $this->lastname;
|
||||
}
|
||||
|
||||
public function separatedName(): string
|
||||
{
|
||||
return $this->lastname.', '.$this->firstname;
|
||||
return $this->lastname . ', ' . $this->firstname;
|
||||
}
|
||||
|
||||
public function fullAddress(): string
|
||||
{
|
||||
return $this->address.', '.$this->zip.' '.$this->location;
|
||||
return $this->address . ', ' . $this->zip . ' ' . $this->location;
|
||||
}
|
||||
|
||||
public function city(): string
|
||||
{
|
||||
return $this->zip.' '.$this->location;
|
||||
return $this->zip . ' ' . $this->location;
|
||||
}
|
||||
|
||||
public function age(): string
|
||||
public function age(): int
|
||||
{
|
||||
return (string) $this->birthday->diffInYears(now()) ?: '';
|
||||
return intval($this->birthday->diffInYears(now()));
|
||||
}
|
||||
|
||||
public function birthYear(): string
|
||||
{
|
||||
return (string) $this->birthday->year;
|
||||
}
|
||||
|
||||
public function birthdayHuman(): string
|
||||
{
|
||||
return $this->birthday->format('d.m.Y');
|
||||
}
|
||||
|
||||
public function genderLetter(): string
|
||||
{
|
||||
return $this->gender->short;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,22 +2,25 @@
|
|||
|
||||
namespace App\Contribution\Documents;
|
||||
|
||||
use App\Contribution\Contracts\HasContributionData;
|
||||
use App\Contribution\Data\MemberData;
|
||||
use App\Contribution\Traits\HasPdfBackground;
|
||||
use App\Country;
|
||||
use App\Form\Enums\SpecialType;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
use Zoomyboy\Tex\Engine;
|
||||
use Zoomyboy\Tex\Template;
|
||||
|
||||
class BdkjHesse extends ContributionDocument
|
||||
{
|
||||
|
||||
use HasPdfBackground;
|
||||
|
||||
/**
|
||||
* @param Collection<int, Collection<int, MemberData>> $members
|
||||
*/
|
||||
public function __construct(
|
||||
public string $dateFrom,
|
||||
public string $dateUntil,
|
||||
public Carbon $dateFrom,
|
||||
public Carbon $dateUntil,
|
||||
public string $zipLocation,
|
||||
public ?Country $country,
|
||||
public Collection $members,
|
||||
|
@ -25,6 +28,7 @@ class BdkjHesse extends ContributionDocument
|
|||
public ?string $filename = '',
|
||||
public string $type = 'F',
|
||||
) {
|
||||
$this->setEventName($eventName);
|
||||
}
|
||||
|
||||
public function dateFrom(): string
|
||||
|
@ -37,33 +41,15 @@ class BdkjHesse extends ContributionDocument
|
|||
return Carbon::parse($this->dateUntil)->format('d.m.Y');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function fromRequest(array $request): self
|
||||
public static function fromPayload(HasContributionData $request): self
|
||||
{
|
||||
return new self(
|
||||
dateFrom: $request['dateFrom'],
|
||||
dateUntil: $request['dateUntil'],
|
||||
zipLocation: $request['zipLocation'],
|
||||
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||
members: MemberData::fromModels($request['members'])->chunk(20),
|
||||
eventName: $request['eventName'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function fromApiRequest(array $request): self
|
||||
{
|
||||
return new self(
|
||||
dateFrom: $request['dateFrom'],
|
||||
dateUntil: $request['dateUntil'],
|
||||
zipLocation: $request['zipLocation'],
|
||||
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||
members: MemberData::fromApi($request['member_data'])->chunk(20),
|
||||
eventName: $request['eventName'],
|
||||
dateFrom: $request->dateFrom(),
|
||||
dateUntil: $request->dateUntil(),
|
||||
zipLocation: $request->zipLocation(),
|
||||
country: $request->country(),
|
||||
members: $request->members()->chunk(20),
|
||||
eventName: $request->eventName(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -74,7 +60,7 @@ class BdkjHesse extends ContributionDocument
|
|||
|
||||
public function durationDays(): int
|
||||
{
|
||||
return Carbon::parse($this->dateUntil)->diffInDays(Carbon::parse($this->dateFrom)) + 1;
|
||||
return intVal(Carbon::parse($this->dateUntil)->diffInDays(Carbon::parse($this->dateFrom))) + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,36 +100,9 @@ class BdkjHesse extends ContributionDocument
|
|||
return $member->birthYear();
|
||||
}
|
||||
|
||||
public function basename(): string
|
||||
{
|
||||
return 'zuschuesse-bdkj-hessen' . Str::slug($this->eventName);
|
||||
}
|
||||
|
||||
public function view(): string
|
||||
{
|
||||
return 'tex.contribution.bdkj-hesse';
|
||||
}
|
||||
|
||||
public function template(): Template
|
||||
{
|
||||
return Template::make('tex.templates.contribution');
|
||||
}
|
||||
|
||||
public function setFilename(string $filename): static
|
||||
{
|
||||
$this->filename = $filename;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEngine(): Engine
|
||||
{
|
||||
return Engine::PDFLATEX;
|
||||
}
|
||||
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'Für BDKJ Hessen erstellen';
|
||||
return 'BDKJ Hessen';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -156,7 +115,17 @@ class BdkjHesse extends ContributionDocument
|
|||
'dateUntil' => 'required|string|date_format:Y-m-d',
|
||||
'country' => 'required|integer|exists:countries,id',
|
||||
'zipLocation' => 'required|string',
|
||||
'eventName' => 'required|string',
|
||||
];
|
||||
}
|
||||
|
||||
public static function requiredFormSpecialTypes(): array {
|
||||
return [
|
||||
SpecialType::FIRSTNAME,
|
||||
SpecialType::LASTNAME,
|
||||
SpecialType::BIRTHDAY,
|
||||
SpecialType::ZIP,
|
||||
SpecialType::LOCATION,
|
||||
SpecialType::GENDER,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,25 +2,29 @@
|
|||
|
||||
namespace App\Contribution\Documents;
|
||||
|
||||
use App\Contribution\Contracts\HasContributionData;
|
||||
use App\Contribution\Data\MemberData;
|
||||
use App\Contribution\Traits\FormatsDates;
|
||||
use App\Contribution\Traits\HasPdfBackground;
|
||||
use App\Country;
|
||||
use App\Form\Enums\SpecialType;
|
||||
use App\Invoice\InvoiceSettings;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
use Zoomyboy\Tex\Engine;
|
||||
use Zoomyboy\Tex\Template;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CityFrankfurtMainDocument extends ContributionDocument
|
||||
{
|
||||
use HasPdfBackground;
|
||||
use FormatsDates;
|
||||
|
||||
public string $fromName;
|
||||
|
||||
/**
|
||||
* @param Collection<int, Collection<int, MemberData>> $members
|
||||
*/
|
||||
public function __construct(
|
||||
public string $dateFrom,
|
||||
public string $dateUntil,
|
||||
public Carbon $dateFrom,
|
||||
public Carbon $dateUntil,
|
||||
public string $zipLocation,
|
||||
public ?Country $country,
|
||||
public Collection $members,
|
||||
|
@ -28,50 +32,22 @@ class CityFrankfurtMainDocument extends ContributionDocument
|
|||
public ?string $filename = '',
|
||||
public string $type = 'F',
|
||||
) {
|
||||
$this->setEventName($eventName);
|
||||
$this->fromName = app(InvoiceSettings::class)->from_long;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function fromRequest(array $request): self
|
||||
public static function fromPayload(HasContributionData $request): self
|
||||
{
|
||||
return new self(
|
||||
dateFrom: $request['dateFrom'],
|
||||
dateUntil: $request['dateUntil'],
|
||||
zipLocation: $request['zipLocation'],
|
||||
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||
members: MemberData::fromModels($request['members'])->chunk(15),
|
||||
eventName: $request['eventName'],
|
||||
dateFrom: $request->dateFrom(),
|
||||
dateUntil: $request->dateUntil(),
|
||||
zipLocation: $request->zipLocation(),
|
||||
country: $request->country(),
|
||||
members: $request->members()->chunk(15),
|
||||
eventName: $request->eventName(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function fromApiRequest(array $request): self
|
||||
{
|
||||
return new self(
|
||||
dateFrom: $request['dateFrom'],
|
||||
dateUntil: $request['dateUntil'],
|
||||
zipLocation: $request['zipLocation'],
|
||||
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||
members: MemberData::fromApi($request['member_data'])->chunk(15),
|
||||
eventName: $request['eventName'],
|
||||
);
|
||||
}
|
||||
|
||||
public function dateFromHuman(): string
|
||||
{
|
||||
return Carbon::parse($this->dateFrom)->format('d.m.Y');
|
||||
}
|
||||
|
||||
public function dateUntilHuman(): string
|
||||
{
|
||||
return Carbon::parse($this->dateUntil)->format('d.m.Y');
|
||||
}
|
||||
|
||||
|
||||
public function countryName(): string
|
||||
{
|
||||
return $this->country->name;
|
||||
|
@ -82,56 +58,9 @@ class CityFrankfurtMainDocument extends ContributionDocument
|
|||
return count($this->members);
|
||||
}
|
||||
|
||||
public function memberShort(MemberData $member): string
|
||||
{
|
||||
return $member->isLeader ? 'L' : '';
|
||||
}
|
||||
|
||||
public function memberName(MemberData $member): string
|
||||
{
|
||||
return $member->separatedName();
|
||||
}
|
||||
|
||||
public function memberAddress(MemberData $member): string
|
||||
{
|
||||
return $member->fullAddress();
|
||||
}
|
||||
|
||||
public function memberAge(MemberData $member): string
|
||||
{
|
||||
return $member->age();
|
||||
}
|
||||
|
||||
public function basename(): string
|
||||
{
|
||||
return 'zuschuesse-frankfurt-' . Str::slug($this->eventName);
|
||||
}
|
||||
|
||||
public function view(): string
|
||||
{
|
||||
return 'tex.contribution.city-frankfurt-main';
|
||||
}
|
||||
|
||||
public function template(): Template
|
||||
{
|
||||
return Template::make('tex.templates.contribution');
|
||||
}
|
||||
|
||||
public function setFilename(string $filename): static
|
||||
{
|
||||
$this->filename = $filename;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEngine(): Engine
|
||||
{
|
||||
return Engine::PDFLATEX;
|
||||
}
|
||||
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'Für Frankfurt erstellen';
|
||||
return 'Frankfurt';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -144,7 +73,17 @@ class CityFrankfurtMainDocument extends ContributionDocument
|
|||
'dateUntil' => 'required|string|date_format:Y-m-d',
|
||||
'country' => 'required|integer|exists:countries,id',
|
||||
'zipLocation' => 'required|string',
|
||||
'eventName' => 'required|string',
|
||||
];
|
||||
}
|
||||
|
||||
public static function requiredFormSpecialTypes(): array {
|
||||
return [
|
||||
SpecialType::FIRSTNAME,
|
||||
SpecialType::LASTNAME,
|
||||
SpecialType::BIRTHDAY,
|
||||
SpecialType::ZIP,
|
||||
SpecialType::LOCATION,
|
||||
SpecialType::ADDRESS,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,107 +2,56 @@
|
|||
|
||||
namespace App\Contribution\Documents;
|
||||
|
||||
use App\Contribution\Data\MemberData;
|
||||
use App\Contribution\Contracts\HasContributionData;
|
||||
use App\Contribution\Traits\FormatsDates;
|
||||
use App\Contribution\Traits\HasPdfBackground;
|
||||
use App\Country;
|
||||
use App\Form\Enums\SpecialType;
|
||||
use App\Member\Member;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Zoomyboy\Tex\Engine;
|
||||
use Zoomyboy\Tex\Template;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CityRemscheidDocument extends ContributionDocument
|
||||
{
|
||||
use HasPdfBackground;
|
||||
use FormatsDates;
|
||||
|
||||
/**
|
||||
* @param Collection<int, Collection<int, Member>> $leaders
|
||||
* @param Collection<int, Collection<int, Member>> $children
|
||||
*/
|
||||
public function __construct(
|
||||
public string $dateFrom,
|
||||
public string $dateUntil,
|
||||
public Carbon $dateFrom,
|
||||
public Carbon $dateUntil,
|
||||
public string $zipLocation,
|
||||
public ?Country $country,
|
||||
public Collection $leaders,
|
||||
public Collection $children,
|
||||
public ?string $filename = '',
|
||||
public string $type = 'F',
|
||||
public string $eventName = '',
|
||||
) {
|
||||
$this->setEventName($eventName);
|
||||
}
|
||||
|
||||
public function niceDateFrom(): string
|
||||
public static function fromPayload(HasContributionData $request): self
|
||||
{
|
||||
return Carbon::parse($this->dateFrom)->format('d.m.Y');
|
||||
}
|
||||
|
||||
public function niceDateUntil(): string
|
||||
{
|
||||
return Carbon::parse($this->dateUntil)->format('d.m.Y');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function fromRequest(array $request): self
|
||||
{
|
||||
[$leaders, $children] = MemberData::fromModels($request['members'])->partition(fn ($member) => $member->isLeader);
|
||||
[$leaders, $children] = $request->members()->partition(fn ($member) => $member->isLeader);
|
||||
|
||||
return new self(
|
||||
dateFrom: $request['dateFrom'],
|
||||
dateUntil: $request['dateUntil'],
|
||||
zipLocation: $request['zipLocation'],
|
||||
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||
dateFrom: $request->dateFrom(),
|
||||
dateUntil: $request->dateUntil(),
|
||||
zipLocation: $request->zipLocation(),
|
||||
country: $request->country(),
|
||||
leaders: $leaders->values()->toBase()->chunk(6),
|
||||
children: $children->values()->toBase()->chunk(20),
|
||||
eventName: $request->eventName(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function fromApiRequest(array $request): self
|
||||
{
|
||||
$members = MemberData::fromApi($request['member_data']);
|
||||
[$leaders, $children] = $members->partition(fn ($member) => $member->isLeader);
|
||||
|
||||
return new self(
|
||||
dateFrom: $request['dateFrom'],
|
||||
dateUntil: $request['dateUntil'],
|
||||
zipLocation: $request['zipLocation'],
|
||||
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||
leaders: $leaders->values()->toBase()->chunk(6),
|
||||
children: $children->values()->toBase()->chunk(20),
|
||||
);
|
||||
}
|
||||
|
||||
public function basename(): string
|
||||
{
|
||||
return 'zuschuesse-remscheid';
|
||||
}
|
||||
|
||||
public function view(): string
|
||||
{
|
||||
return 'tex.contribution.city-remscheid';
|
||||
}
|
||||
|
||||
public function template(): Template
|
||||
{
|
||||
return Template::make('tex.templates.contribution');
|
||||
}
|
||||
|
||||
public function setFilename(string $filename): static
|
||||
{
|
||||
$this->filename = $filename;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEngine(): Engine
|
||||
{
|
||||
return Engine::PDFLATEX;
|
||||
}
|
||||
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'Für Remscheid erstellen';
|
||||
return 'Remscheid';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -117,4 +66,15 @@ class CityRemscheidDocument extends ContributionDocument
|
|||
'country' => 'required|integer|exists:countries,id',
|
||||
];
|
||||
}
|
||||
|
||||
public static function requiredFormSpecialTypes(): array {
|
||||
return [
|
||||
SpecialType::FIRSTNAME,
|
||||
SpecialType::LASTNAME,
|
||||
SpecialType::ADDRESS,
|
||||
SpecialType::BIRTHDAY,
|
||||
SpecialType::ZIP,
|
||||
SpecialType::LOCATION,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
namespace App\Contribution\Documents;
|
||||
|
||||
use App\Contribution\Contracts\HasContributionData;
|
||||
use App\Contribution\Data\MemberData;
|
||||
use App\Form\Enums\SpecialType;
|
||||
use App\Invoice\InvoiceSettings;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
use Zoomyboy\Tex\Engine;
|
||||
use Zoomyboy\Tex\Template;
|
||||
|
||||
class CitySolingenDocument extends ContributionDocument
|
||||
{
|
||||
|
@ -18,41 +18,28 @@ class CitySolingenDocument extends ContributionDocument
|
|||
* @param Collection<int, MemberData> $members
|
||||
*/
|
||||
final private function __construct(
|
||||
public string $dateFrom,
|
||||
public string $dateUntil,
|
||||
public Carbon $dateFrom,
|
||||
public Carbon $dateUntil,
|
||||
public string $zipLocation,
|
||||
public Collection $members,
|
||||
public string $eventName,
|
||||
public string $type = 'F',
|
||||
) {
|
||||
$this->setEventName($eventName);
|
||||
$this->fromName = app(InvoiceSettings::class)->from_long;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function fromRequest(array $request): static
|
||||
public static function fromPayload(HasContributionData $request): static
|
||||
{
|
||||
return new static(
|
||||
dateFrom: $request['dateFrom'],
|
||||
dateUntil: $request['dateUntil'],
|
||||
zipLocation: $request['zipLocation'],
|
||||
members: MemberData::fromModels($request['members']),
|
||||
eventName: $request['eventName'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function fromApiRequest(array $request): static
|
||||
{
|
||||
return new static(
|
||||
dateFrom: $request['dateFrom'],
|
||||
dateUntil: $request['dateUntil'],
|
||||
zipLocation: $request['zipLocation'],
|
||||
members: MemberData::fromApi($request['member_data']),
|
||||
eventName: $request['eventName'],
|
||||
dateFrom: $request->dateFrom(),
|
||||
dateUntil: $request->dateUntil(),
|
||||
zipLocation: $request->zipLocation(),
|
||||
members: $request->members(),
|
||||
eventName: $request->eventName(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -74,15 +61,8 @@ class CitySolingenDocument extends ContributionDocument
|
|||
return Carbon::parse($this->dateUntil)->format('d.m.Y');
|
||||
}
|
||||
|
||||
public function template(): Template
|
||||
{
|
||||
return Template::make('tex.templates.contribution');
|
||||
}
|
||||
|
||||
public function checkboxes(): string
|
||||
{
|
||||
$output = '';
|
||||
|
||||
$firstRow = collect(['B' => 'Jugendbildungsmaßnahme', 'G' => 'Gruppenleiter/innenschulung', 'FK' => 'Ferienkolonie', 'F' => 'Freizeitnaßnahme'])->map(function ($item, $key) {
|
||||
return ($this->type === $key ? '\\checkedcheckbox' : '\\checkbox') . '{' . $item . '}';
|
||||
})->implode(' & ') . ' \\\\';
|
||||
|
@ -94,16 +74,6 @@ class CitySolingenDocument extends ContributionDocument
|
|||
return $firstRow . "\n" . $secondRow;
|
||||
}
|
||||
|
||||
public function basename(): string
|
||||
{
|
||||
return 'zuschuesse-solingen-' . Str::slug($this->eventName);
|
||||
}
|
||||
|
||||
public function view(): string
|
||||
{
|
||||
return 'tex.contribution.city-solingen';
|
||||
}
|
||||
|
||||
public function getEngine(): Engine
|
||||
{
|
||||
return Engine::PDFLATEX;
|
||||
|
@ -111,7 +81,7 @@ class CitySolingenDocument extends ContributionDocument
|
|||
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'Für Stadt Solingen erstellen';
|
||||
return 'Stadt Solingen';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,7 +93,17 @@ class CitySolingenDocument extends ContributionDocument
|
|||
'dateFrom' => 'required|string|date_format:Y-m-d',
|
||||
'dateUntil' => 'required|string|date_format:Y-m-d',
|
||||
'zipLocation' => 'required|string',
|
||||
'eventName' => 'required|string',
|
||||
];
|
||||
}
|
||||
|
||||
public static function requiredFormSpecialTypes(): array {
|
||||
return [
|
||||
SpecialType::FIRSTNAME,
|
||||
SpecialType::LASTNAME,
|
||||
SpecialType::BIRTHDAY,
|
||||
SpecialType::ZIP,
|
||||
SpecialType::LOCATION,
|
||||
SpecialType::ADDRESS,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,21 +2,23 @@
|
|||
|
||||
namespace App\Contribution\Documents;
|
||||
|
||||
use App\Contribution\Contracts\HasContributionData;
|
||||
use App\Form\Enums\SpecialType;
|
||||
use Zoomyboy\Tex\Document;
|
||||
use Zoomyboy\Tex\Template;
|
||||
|
||||
abstract class ContributionDocument extends Document
|
||||
{
|
||||
private string $eventName;
|
||||
|
||||
abstract public static function getName(): string;
|
||||
|
||||
/**
|
||||
* @param ContributionRequestArray $request
|
||||
*/
|
||||
abstract public static function fromRequest(array $request): self;
|
||||
abstract public static function fromPayload(HasContributionData $request): self;
|
||||
|
||||
/**
|
||||
* @param ContributionApiRequestArray $request
|
||||
* @return array<int, SpecialType>
|
||||
*/
|
||||
abstract public static function fromApiRequest(array $request): self;
|
||||
abstract public static function requiredFormSpecialTypes(): array;
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
|
@ -29,8 +31,29 @@ abstract class ContributionDocument extends Document
|
|||
public static function globalRules(): array
|
||||
{
|
||||
return [
|
||||
'eventName' => 'required|string',
|
||||
'members' => 'present|array|min:1',
|
||||
'members.*' => 'integer|exists:members,id',
|
||||
];
|
||||
}
|
||||
|
||||
public function setEventName(string $eventName): void
|
||||
{
|
||||
$this->eventName = $eventName;
|
||||
}
|
||||
|
||||
public function basename(): string
|
||||
{
|
||||
return str('Zuschüsse ')->append($this->getName())->append(' ')->append($this->eventName)->slug();
|
||||
}
|
||||
|
||||
public function template(): Template
|
||||
{
|
||||
return Template::make('tex.templates.contribution');
|
||||
}
|
||||
|
||||
public function view(): string
|
||||
{
|
||||
return 'tex.contribution.' . str(class_basename(static::class))->replace('Document', '')->kebab()->toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,61 +2,45 @@
|
|||
|
||||
namespace App\Contribution\Documents;
|
||||
|
||||
use App\Contribution\Contracts\HasContributionData;
|
||||
use App\Contribution\Data\MemberData;
|
||||
use App\Contribution\Traits\FormatsDates;
|
||||
use App\Contribution\Traits\HasPdfBackground;
|
||||
use App\Country;
|
||||
use Carbon\Carbon;
|
||||
use App\Form\Enums\SpecialType;
|
||||
use Illuminate\Support\Collection;
|
||||
use Zoomyboy\Tex\Engine;
|
||||
use Zoomyboy\Tex\Template;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class RdpNrwDocument extends ContributionDocument
|
||||
{
|
||||
use HasPdfBackground;
|
||||
use FormatsDates;
|
||||
|
||||
/**
|
||||
* @param Collection<int, Collection<int, MemberData>> $members
|
||||
*/
|
||||
public function __construct(
|
||||
public string $dateFrom,
|
||||
public string $dateUntil,
|
||||
public Carbon $dateFrom,
|
||||
public Carbon $dateUntil,
|
||||
public string $zipLocation,
|
||||
public ?Country $country,
|
||||
public Collection $members,
|
||||
public ?string $filename = '',
|
||||
public string $type = 'F',
|
||||
public string $eventName = '',
|
||||
) {
|
||||
$this->setEventName($eventName);
|
||||
}
|
||||
|
||||
public function dateRange(): string
|
||||
{
|
||||
return Carbon::parse($this->dateFrom)->format('d.m.Y')
|
||||
. ' - '
|
||||
. Carbon::parse($this->dateUntil)->format('d.m.Y');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function fromRequest(array $request): self
|
||||
public static function fromPayload(HasContributionData $request): self
|
||||
{
|
||||
return new self(
|
||||
dateFrom: $request['dateFrom'],
|
||||
dateUntil: $request['dateUntil'],
|
||||
zipLocation: $request['zipLocation'],
|
||||
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||
members: MemberData::fromModels($request['members'])->chunk(17),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function fromApiRequest(array $request): self
|
||||
{
|
||||
return new self(
|
||||
dateFrom: $request['dateFrom'],
|
||||
dateUntil: $request['dateUntil'],
|
||||
zipLocation: $request['zipLocation'],
|
||||
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||
members: MemberData::fromApi($request['member_data'])->chunk(17),
|
||||
dateFrom: $request->dateFrom(),
|
||||
dateUntil: $request->dateUntil(),
|
||||
zipLocation: $request->zipLocation(),
|
||||
country: $request->country(),
|
||||
members: $request->members()->chunk(17),
|
||||
eventName: $request->eventName(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -65,65 +49,9 @@ class RdpNrwDocument extends ContributionDocument
|
|||
return $this->country->name;
|
||||
}
|
||||
|
||||
public function memberShort(MemberData $member): string
|
||||
{
|
||||
return $member->isLeader ? 'L' : '';
|
||||
}
|
||||
|
||||
public function memberName(MemberData $member): string
|
||||
{
|
||||
return $member->separatedName();
|
||||
}
|
||||
|
||||
public function memberAddress(MemberData $member): string
|
||||
{
|
||||
return $member->fullAddress();
|
||||
}
|
||||
|
||||
public function memberGender(MemberData $member): string
|
||||
{
|
||||
if (!$member->gender) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return strtolower(substr($member->gender->name, 0, 1));
|
||||
}
|
||||
|
||||
public function memberAge(MemberData $member): string
|
||||
{
|
||||
return $member->age();
|
||||
}
|
||||
|
||||
public function basename(): string
|
||||
{
|
||||
return 'zuschuesse-rdp-nrw';
|
||||
}
|
||||
|
||||
public function view(): string
|
||||
{
|
||||
return 'tex.contribution.rdp-nrw';
|
||||
}
|
||||
|
||||
public function template(): Template
|
||||
{
|
||||
return Template::make('tex.templates.contribution');
|
||||
}
|
||||
|
||||
public function setFilename(string $filename): static
|
||||
{
|
||||
$this->filename = $filename;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEngine(): Engine
|
||||
{
|
||||
return Engine::PDFLATEX;
|
||||
}
|
||||
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'Für RdP NRW erstellen';
|
||||
return 'RdP NRW';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -136,7 +64,17 @@ class RdpNrwDocument extends ContributionDocument
|
|||
'dateUntil' => 'required|string|date_format:Y-m-d',
|
||||
'country' => 'required|integer|exists:countries,id',
|
||||
'zipLocation' => 'required|string',
|
||||
'eventName' => 'required|string',
|
||||
];
|
||||
}
|
||||
|
||||
public static function requiredFormSpecialTypes(): array {
|
||||
return [
|
||||
SpecialType::FIRSTNAME,
|
||||
SpecialType::LASTNAME,
|
||||
SpecialType::BIRTHDAY,
|
||||
SpecialType::ZIP,
|
||||
SpecialType::LOCATION,
|
||||
SpecialType::GENDER,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contribution\Documents;
|
||||
|
||||
use App\Contribution\Contracts\HasContributionData;
|
||||
use App\Contribution\Data\MemberData;
|
||||
use App\Contribution\Traits\FormatsDates;
|
||||
use App\Contribution\Traits\HasPdfBackground;
|
||||
use App\Country;
|
||||
use App\Form\Enums\SpecialType;
|
||||
use Illuminate\Support\Collection;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class WuppertalDocument extends ContributionDocument
|
||||
{
|
||||
|
||||
use HasPdfBackground;
|
||||
use FormatsDates;
|
||||
|
||||
/**
|
||||
* @param Collection<int, Collection<int, MemberData>> $members
|
||||
*/
|
||||
public function __construct(
|
||||
public Carbon $dateFrom,
|
||||
public Carbon $dateUntil,
|
||||
public string $zipLocation,
|
||||
public ?Country $country,
|
||||
public Collection $members,
|
||||
public ?string $filename = '',
|
||||
public string $type = 'F',
|
||||
public string $eventName = '',
|
||||
) {
|
||||
$this->setEventName($eventName);
|
||||
}
|
||||
|
||||
public static function fromPayload(HasContributionData $request): self
|
||||
{
|
||||
return new self(
|
||||
dateFrom: $request->dateFrom(),
|
||||
dateUntil: $request->dateUntil(),
|
||||
zipLocation: $request->zipLocation(),
|
||||
country: $request->country(),
|
||||
members: $request->members()->chunk(14),
|
||||
eventName: $request->eventName(),
|
||||
);
|
||||
}
|
||||
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'Wuppertal';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function rules(): array
|
||||
{
|
||||
return [
|
||||
'dateFrom' => 'required|string|date_format:Y-m-d',
|
||||
'dateUntil' => 'required|string|date_format:Y-m-d',
|
||||
'zipLocation' => 'required|string',
|
||||
];
|
||||
}
|
||||
|
||||
public static function requiredFormSpecialTypes(): array {
|
||||
return [
|
||||
SpecialType::FIRSTNAME,
|
||||
SpecialType::LASTNAME,
|
||||
SpecialType::ADDRESS,
|
||||
SpecialType::BIRTHDAY,
|
||||
SpecialType::ZIP,
|
||||
SpecialType::LOCATION,
|
||||
SpecialType::GENDER,
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,256 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contribution\Enums;
|
||||
|
||||
enum Country: string {
|
||||
case AD = 'Andorra';
|
||||
case AE = 'Vereinigte Arabische Emirate';
|
||||
case AF = 'Afghanistan';
|
||||
case AG = 'Antigua und Barbuda';
|
||||
case AI = 'Anguilla';
|
||||
case AL = 'Albanien';
|
||||
case AM = 'Armenien';
|
||||
case AN = 'Niederländische Antillen';
|
||||
case AO = 'Angola';
|
||||
case AQ = 'Antarktis';
|
||||
case AR = 'Argentinien';
|
||||
case AS = 'Amerikanisch-Samoa';
|
||||
case AT = 'Österreich (Austria)';
|
||||
case AU = 'Australien';
|
||||
case AW = 'Aruba';
|
||||
case AZ = 'Azerbaijan';
|
||||
case BA = 'Bosnien-Herzegovina';
|
||||
case BB = 'Barbados';
|
||||
case BD = 'Bangladesh';
|
||||
case BE = 'Belgien';
|
||||
case BF = 'Burkina Faso';
|
||||
case BG = 'Bulgarien';
|
||||
case BH = 'Bahrain';
|
||||
case BI = 'Burundi';
|
||||
case BJ = 'Benin';
|
||||
case BM = 'Bermudas';
|
||||
case BN = 'Brunei Darussalam';
|
||||
case BO = 'Bolivien';
|
||||
case BR = 'Brasilien';
|
||||
case BS = 'Bahamas';
|
||||
case BT = 'Bhutan';
|
||||
case BV = 'Bouvet Island';
|
||||
case BW = 'Botswana';
|
||||
case BY = 'Weißrußland (Belarus)';
|
||||
case BZ = 'Belize';
|
||||
case CA = 'Canada';
|
||||
case CC = 'Cocos (Keeling) Islands';
|
||||
case CD = 'Demokratische Republik Kongo';
|
||||
case CF = 'Zentralafrikanische Republik';
|
||||
case CG = 'Kongo';
|
||||
case CH = 'Schweiz';
|
||||
case CI = 'Elfenbeinküste (Cote D’Ivoire)';
|
||||
case CK = 'Cook Islands';
|
||||
case CL = 'Chile';
|
||||
case CM = 'Kamerun';
|
||||
case CN = 'China';
|
||||
case CO = 'Kolumbien';
|
||||
case CR = 'Costa Rica';
|
||||
case CS = 'Tschechoslowakei (ehemalige)';
|
||||
case CU = 'Kuba';
|
||||
case CV = 'Kap Verde';
|
||||
case CX = 'Christmas Island';
|
||||
case CY = 'Zypern';
|
||||
case CZ = 'Tschechische Republik';
|
||||
case DE = 'Deutschland';
|
||||
case DJ = 'Djibouti';
|
||||
case DK = 'Dänemark';
|
||||
case DM = 'Dominica';
|
||||
case DO = 'Dominikanische Republik';
|
||||
case DZ = 'Algerien';
|
||||
case EC = 'Ecuador';
|
||||
case EE = 'Estland';
|
||||
case EG = 'Ägypten';
|
||||
case EH = 'Westsahara';
|
||||
case ER = 'Eritrea';
|
||||
case ES = 'Spanien';
|
||||
case ET = 'Äthiopien';
|
||||
case FI = 'Finnland';
|
||||
case FJ = 'Fiji';
|
||||
case FK = 'Falkland-Inseln (Malvinas)';
|
||||
case FM = 'Micronesien';
|
||||
case FO = 'Faröer-Inseln';
|
||||
case FR = 'Frankreich';
|
||||
case FX = 'France, Metropolitan';
|
||||
case GA = 'Gabon';
|
||||
case GD = 'Grenada';
|
||||
case GE = 'Georgien';
|
||||
case GF = 'Französisch Guiana';
|
||||
case GH = 'Ghana';
|
||||
case GI = 'Gibraltar';
|
||||
case GL = 'Grönland';
|
||||
case GM = 'Gambia';
|
||||
case GN = 'Guinea';
|
||||
case GP = 'Guadeloupe';
|
||||
case GQ = 'Äquatorialguinea';
|
||||
case GR = 'Griechenland';
|
||||
case GS = 'Südgeorgien und Südliche Sandwich-Inseln';
|
||||
case GT = 'Guatemala';
|
||||
case GU = 'Guam';
|
||||
case GW = 'Guinea-Bissau';
|
||||
case GY = 'Guyana';
|
||||
case HK = 'Kong Hong';
|
||||
case HM = 'Heard und Mc Donald Islands';
|
||||
case HN = 'Honduras';
|
||||
case HT = 'Haiti';
|
||||
case HU = 'Ungarn';
|
||||
case ID = 'Indonesien';
|
||||
case IE = 'Irland';
|
||||
case IL = 'Israel';
|
||||
case IN = 'Indien';
|
||||
case IO = 'British Indian Ocean Territory';
|
||||
case IQ = 'Irak';
|
||||
case IR = 'Iran (Islamische Republik)';
|
||||
case IS = 'Island';
|
||||
case IT = 'Italien';
|
||||
case JM = 'Jamaica';
|
||||
case JO = 'Jordanien';
|
||||
case JP = 'Japan';
|
||||
case KE = 'Kenya';
|
||||
case KG = 'Kirgisien';
|
||||
case KH = 'Königreich Kambodscha';
|
||||
case KI = 'Kiribati';
|
||||
case KM = 'Komoren';
|
||||
case KN = 'Saint Kitts und Nevis';
|
||||
case KP = 'Korea, Volksrepublik';
|
||||
case KR = 'Korea';
|
||||
case KW = 'Kuwait';
|
||||
case KY = 'Kayman Islands';
|
||||
case KZ = 'Kasachstan';
|
||||
case LA = 'Laos';
|
||||
case LB = 'Libanon';
|
||||
case LC = 'Saint Lucia';
|
||||
case LI = 'Liechtenstein';
|
||||
case LK = 'Sri Lanka';
|
||||
case LR = 'Liberia';
|
||||
case LS = 'Lesotho';
|
||||
case LT = 'Littauen';
|
||||
case LU = 'Luxemburg';
|
||||
case LV = 'Lettland';
|
||||
case LY = 'Libyen';
|
||||
case MA = 'Marokko';
|
||||
case MC = 'Monaco';
|
||||
case MD = 'Moldavien';
|
||||
case MG = 'Madagaskar';
|
||||
case MH = 'Marshall-Inseln';
|
||||
case MK = 'Mazedonien, ehem. Jugoslawische Republik';
|
||||
case ML = 'Mali';
|
||||
case MM = 'Myanmar';
|
||||
case MN = 'Mongolei';
|
||||
case MO = 'Macao';
|
||||
case MP = 'Nördliche Marianneninseln';
|
||||
case MQ = 'Martinique';
|
||||
case MR = 'Mauretanien';
|
||||
case MS = 'Montserrat';
|
||||
case MT = 'Malta';
|
||||
case MU = 'Mauritius';
|
||||
case MV = 'Malediven';
|
||||
case MW = 'Malawi';
|
||||
case MX = 'Mexico';
|
||||
case MY = 'Malaysien';
|
||||
case MZ = 'Mozambique';
|
||||
case NA = 'Namibia';
|
||||
case NC = 'Neu Kaledonien';
|
||||
case NE = 'Niger';
|
||||
case NF = 'Norfolk Island';
|
||||
case NG = 'Nigeria';
|
||||
case NI = 'Nicaragua';
|
||||
case NL = 'Niederlande';
|
||||
case NO = 'Norwegen';
|
||||
case NP = 'Nepal';
|
||||
case NR = 'Nauru';
|
||||
case NU = 'Niue';
|
||||
case NZ = 'Neuseeland';
|
||||
case OM = 'Oman';
|
||||
case PA = 'Panama';
|
||||
case PE = 'Peru';
|
||||
case PF = 'Französisch Polynesien';
|
||||
case PG = 'Papua Neuguinea';
|
||||
case PH = 'Philippinen';
|
||||
case PK = 'Pakistan';
|
||||
case PL = 'Polen';
|
||||
case PM = 'St. Pierre und Miquelon';
|
||||
case PN = 'Pitcairn';
|
||||
case PR = 'Puerto Rico';
|
||||
case PT = 'Portugal';
|
||||
case PW = 'Palau';
|
||||
case PY = 'Paraguay';
|
||||
case QA = 'Katar';
|
||||
case RE = 'Reunion';
|
||||
case RO = 'Rumänien';
|
||||
case RU = 'Russische Föderation';
|
||||
case RW = 'Ruanda';
|
||||
case SA = 'Saudi Arabien';
|
||||
case SB = 'Salomonen';
|
||||
case SC = 'Seychellen';
|
||||
case SD = 'Sudan';
|
||||
case SE = 'Schweden';
|
||||
case SG = 'Singapur';
|
||||
case SH = 'St. Helena';
|
||||
case SI = 'Slovenien';
|
||||
case SJ = 'Svalbard und Jan Mayen Islands';
|
||||
case SK = 'Slowakei';
|
||||
case SL = 'Sierra Leone';
|
||||
case SM = 'San Marino';
|
||||
case SN = 'Senegal';
|
||||
case SO = 'Somalia';
|
||||
case SR = 'Surinam';
|
||||
case ST = 'Sao Tome und Principe';
|
||||
case SV = 'El Salvador';
|
||||
case SY = 'Syrien, Arabische Republik';
|
||||
case SZ = 'Swaziland';
|
||||
case TC = 'Turk und Caicos-Inseln';
|
||||
case TD = 'Tschad';
|
||||
case TF = 'Französisches Südl.Territorium';
|
||||
case TG = 'Togo';
|
||||
case TH = 'Thailand';
|
||||
case TJ = 'Tadschikistan';
|
||||
case TK = 'Tokelau';
|
||||
case TM = 'Turkmenistan';
|
||||
case TN = 'Tunesien';
|
||||
case TO = 'Tonga';
|
||||
case TP = 'Ost-Timor';
|
||||
case TR = 'Türkei';
|
||||
case TT = 'Trinidad und Tobago';
|
||||
case TV = 'Tuvalu';
|
||||
case TW = 'Taiwan';
|
||||
case TZ = 'Tansania, United Republic of';
|
||||
case UA = 'Ukraine';
|
||||
case UG = 'Uganda';
|
||||
case GB = 'Großbritannien';
|
||||
case US = 'Vereinigte Staaten';
|
||||
case UM = 'Vereinigte Staaten, Minor Outlying Islands';
|
||||
case UY = 'Uruguay';
|
||||
case UZ = 'Usbekistan';
|
||||
case VA = 'Vatikanstaat';
|
||||
case VC = 'Saint Vincent und Grenadines';
|
||||
case VE = 'Venezuela';
|
||||
case VG = 'Virgin Islands (Britisch)';
|
||||
case VI = 'Virgin Islands (U.S.)';
|
||||
case VN = 'Vietnam';
|
||||
case VU = 'Vanuatu';
|
||||
case WF = 'Wallis und Futuna Islands';
|
||||
case WS = 'Samoa';
|
||||
case YE = 'Jemen';
|
||||
case YT = 'Mayotte';
|
||||
case YU = 'Jugoslawien';
|
||||
case ZA = 'Südafrika';
|
||||
case ZM = 'Sambia';
|
||||
case ZW = 'Zimbabw';
|
||||
|
||||
/**
|
||||
* @return array<int, array{name: string, id: string}>
|
||||
*/
|
||||
public static function forSelect(): array
|
||||
{
|
||||
return collect(static::cases())
|
||||
->map(fn ($case) => ['id' => $case->value, 'name' => $case->value])
|
||||
->toArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contribution\Requests;
|
||||
|
||||
use App\Contribution\Data\MemberData;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class GenerateApiRequest extends GenerateRequest {
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function payload(): array
|
||||
{
|
||||
return $this->input();
|
||||
}
|
||||
|
||||
public function validateContribution(): void {
|
||||
}
|
||||
|
||||
public function members(): Collection {
|
||||
return MemberData::fromApi($this->value('members'));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contribution\Requests;
|
||||
|
||||
use App\Contribution\Contracts\HasContributionData;
|
||||
use App\Contribution\ContributionFactory;
|
||||
use App\Contribution\Data\MemberData;
|
||||
use App\Contribution\Documents\ContributionDocument;
|
||||
use App\Country;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class GenerateRequest extends ActionRequest implements HasContributionData {
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function payload(): array
|
||||
{
|
||||
return json_decode(rawurldecode(base64_decode($this->input('payload', ''))), true);
|
||||
}
|
||||
|
||||
public function validateContribution(): void {
|
||||
Validator::make($this->payload(), app(ContributionFactory::class)->rules($this->type()))->validate();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|array<array-key, mixed>
|
||||
*/
|
||||
public function value(string $key): string|array
|
||||
{
|
||||
return data_get($this->payload(), $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class-string<ContributionDocument>
|
||||
*/
|
||||
public function type(): string
|
||||
{
|
||||
return $this->value('type');
|
||||
}
|
||||
|
||||
public function dateFrom(): Carbon {
|
||||
return Carbon::parse($this->value('dateFrom'));
|
||||
}
|
||||
|
||||
public function dateUntil(): Carbon {
|
||||
return Carbon::parse($this->value('dateUntil'));
|
||||
}
|
||||
|
||||
public function zipLocation(): string {
|
||||
return $this->value('zipLocation');
|
||||
}
|
||||
|
||||
public function eventName(): string {
|
||||
return $this->value('eventName');
|
||||
}
|
||||
|
||||
public function members(): Collection {
|
||||
return MemberData::fromModels($this->value('members'));
|
||||
}
|
||||
|
||||
public function country(): ?Country {
|
||||
return Country::where('id', $this->value('country'))->first();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contribution\Traits;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
trait FormatsDates
|
||||
{
|
||||
|
||||
public function niceDateFrom(): string
|
||||
{
|
||||
return Carbon::parse($this->dateFrom)->format('d.m.Y');
|
||||
}
|
||||
|
||||
public function niceDateUntil(): string
|
||||
{
|
||||
return Carbon::parse($this->dateUntil)->format('d.m.Y');
|
||||
}
|
||||
|
||||
public function dateRange(): string
|
||||
{
|
||||
return implode(' - ', [$this->niceDateFrom(), $this->niceDateUntil()]);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contribution\Traits;
|
||||
|
||||
use Zoomyboy\Tex\Engine;
|
||||
|
||||
trait HasPdfBackground
|
||||
{
|
||||
public function getEngine(): Engine
|
||||
{
|
||||
return Engine::PDFLATEX;
|
||||
}
|
||||
}
|
|
@ -3,11 +3,13 @@
|
|||
namespace App;
|
||||
|
||||
use App\Nami\HasNamiField;
|
||||
use Database\Factories\CountryFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Country extends Model
|
||||
{
|
||||
/** @use HasFactory<CountryFactory> */
|
||||
use HasFactory;
|
||||
use HasNamiField;
|
||||
|
||||
|
|
|
@ -3,11 +3,13 @@
|
|||
namespace App\Course\Models;
|
||||
|
||||
use App\Nami\HasNamiField;
|
||||
use Database\Factories\Course\Models\CourseFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Course extends Model
|
||||
{
|
||||
/** @use HasFactory<CourseFactory> */
|
||||
use HasFactory;
|
||||
use HasNamiField;
|
||||
|
||||
|
|
|
@ -3,19 +3,21 @@
|
|||
namespace App\Course\Models;
|
||||
|
||||
use App\Member\Member;
|
||||
use Database\Factories\Course\Models\CourseMemberFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class CourseMember extends Model
|
||||
{
|
||||
/** @use HasFactory<CourseMemberFactory> */
|
||||
use HasFactory;
|
||||
|
||||
/** @var array<int, string> */
|
||||
public $guarded = [];
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Course, self>
|
||||
* @return BelongsTo<Course, $this>
|
||||
*/
|
||||
public function course(): BelongsTo
|
||||
{
|
||||
|
@ -23,7 +25,7 @@ class CourseMember extends Model
|
|||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Member, self>
|
||||
* @return BelongsTo<Member, $this>
|
||||
*/
|
||||
public function member(): BelongsTo
|
||||
{
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace App\Dashboard;
|
||||
|
||||
use Illuminate\Routing\Router;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use App\Dashboard\Actions\IndexAction as DashboardIndexAction;
|
||||
|
||||
class DashboardServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
@ -23,5 +25,8 @@ class DashboardServiceProvider extends ServiceProvider
|
|||
*/
|
||||
public function boot()
|
||||
{
|
||||
app(Router::class)->middleware(['web', 'auth:web'])->group(function ($router) {
|
||||
$router->get('/', DashboardIndexAction::class)->name('home');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,6 +129,7 @@ class Principal implements PrincipalBackendInterface
|
|||
*/
|
||||
public function findByUri($uri, $principalPrefix)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -178,7 +179,7 @@ class Principal implements PrincipalBackendInterface
|
|||
private function userToPrincipal(User $user): array
|
||||
{
|
||||
return [
|
||||
'{DAV:}displayname' => $user->name,
|
||||
'{DAV:}displayname' => $user->firstname . ' ' . $user->lastname,
|
||||
'uri' => 'principals/' . $user->email,
|
||||
'{http://sabredav.org/ns}email-address' => $user->email,
|
||||
];
|
||||
|
|
|
@ -19,7 +19,7 @@ class EfzPendingBlock extends Block
|
|||
})
|
||||
->whereCurrentGroup()
|
||||
->orderByRaw('lastname, firstname')
|
||||
->whereHas('memberships', fn ($builder) => $builder->isLeader());
|
||||
->whereHas('memberships', fn ($builder) => $builder->isLeader()->active());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,23 +4,24 @@ namespace App;
|
|||
|
||||
use App\Nami\HasNamiField;
|
||||
use App\Payment\Subscription;
|
||||
use Database\Factories\FeeFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Fee extends Model
|
||||
{
|
||||
/** @use HasFactory<FeeFactory> */
|
||||
use HasFactory;
|
||||
use HasNamiField;
|
||||
|
||||
/** @var array<int, string> */
|
||||
public $fillable = ['name', 'nami_id'];
|
||||
|
||||
/** @var bool */
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* @return HasMany<Subscription>
|
||||
* @return HasMany<Subscription, $this>
|
||||
*/
|
||||
public function subscriptions(): HasMany
|
||||
{
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Fileshare\Actions;
|
||||
|
||||
use App\Fileshare\Models\Fileshare;
|
||||
use App\Fileshare\Resources\FileshareResource;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class FileshareIndexAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
public function handle(): Response
|
||||
{
|
||||
session()->put('menu', 'setting');
|
||||
session()->put('title', 'Datei-Verbindungen');
|
||||
|
||||
return Inertia::render('fileshare/Index', [
|
||||
'data' => FileshareResource::collection(Fileshare::paginate(15)),
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -17,6 +17,6 @@ class ListFilesAction
|
|||
*/
|
||||
public function handle(ActionRequest $request, Fileshare $fileshare): DataCollection
|
||||
{
|
||||
return ResourceData::collection($fileshare->type->getSubDirectories($request->input('parent')))->wrap('data');
|
||||
return ResourceData::collect($fileshare->type->getSubDirectories($request->input('parent')), DataCollection::class)->wrap('data');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,29 +2,29 @@
|
|||
|
||||
namespace App\Fileshare;
|
||||
|
||||
use App\Fileshare\Actions\FileshareIndexAction;
|
||||
use App\Setting\Contracts\Indexable;
|
||||
use App\Fileshare\Models\Fileshare;
|
||||
use App\Fileshare\Resources\FileshareResource;
|
||||
use App\Setting\LocalSettings;
|
||||
|
||||
class FileshareSettings extends LocalSettings implements Indexable
|
||||
class FileshareSettings extends LocalSettings
|
||||
{
|
||||
public static function group(): string
|
||||
{
|
||||
return 'fileshare';
|
||||
}
|
||||
|
||||
public static function slug(): string
|
||||
{
|
||||
return 'fileshare';
|
||||
}
|
||||
|
||||
public static function indexAction(): string
|
||||
{
|
||||
return FileshareIndexAction::class;
|
||||
}
|
||||
|
||||
public static function title(): string
|
||||
{
|
||||
return 'Datei-Verbindungen';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function viewData(): array
|
||||
{
|
||||
return [
|
||||
'data' => FileshareResource::collection(Fileshare::paginate(15))
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,13 @@
|
|||
namespace App\Fileshare\Models;
|
||||
|
||||
use App\Fileshare\ConnectionTypes\ConnectionType;
|
||||
use Database\Factories\Fileshare\Models\FileshareFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Fileshare extends Model
|
||||
{
|
||||
/** @use HasFactory<FileshareFactory> */
|
||||
use HasFactory;
|
||||
|
||||
public $guarded = [];
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace App\Form\Actions;
|
||||
|
||||
use App\Form\Models\Form;
|
||||
use App\Form\Models\Participant;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
use Zoomyboy\TableDocument\SheetData;
|
||||
use Zoomyboy\TableDocument\TableDocumentData;
|
||||
|
||||
class CreateExcelDocumentAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
public Form $form;
|
||||
|
||||
/**
|
||||
* @param Collection<int, Participant> $participants
|
||||
*/
|
||||
public function handle(Form $form, Collection $participants): string
|
||||
{
|
||||
$this->form = $form;
|
||||
|
||||
return file_get_contents($this->allSheet($participants)->compile($this->tempPath()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection<int, Participant> $participants
|
||||
*/
|
||||
private function allSheet(Collection $participants): TableDocumentData
|
||||
{
|
||||
$document = TableDocumentData::from(['title' => 'Anmeldungen für ' . $this->form->name, 'sheets' => []]);
|
||||
$headers = $this->form->getFields()->map(fn ($field) => $field->name)->toArray();
|
||||
|
||||
$document->addSheet(SheetData::from([
|
||||
'header' => $headers,
|
||||
'data' => $participants
|
||||
->map(fn ($participant) => $this->form->getFields()->map(fn ($field) => $participant->getFields()->find($field)->presentRaw())->toArray())
|
||||
->toArray(),
|
||||
'name' => 'Alle',
|
||||
]));
|
||||
|
||||
if ($this->form->export->groupBy) {
|
||||
$groups = $participants->groupBy(fn ($participant) => $participant->getFields()->findByKey($this->form->export->groupBy)->presentRaw());
|
||||
|
||||
foreach ($groups as $name => $participants) {
|
||||
$document->addSheet(SheetData::from([
|
||||
'header' => $headers,
|
||||
'data' => $participants
|
||||
->map(fn ($participant) => $this->form->getFields()->map(fn ($field) => $participant->getFields()->find($field)->presentRaw())->toArray())
|
||||
->toArray(),
|
||||
'name' => $name,
|
||||
]));
|
||||
}
|
||||
|
||||
$document->addSheet(SheetData::from([
|
||||
'header' => ['Wert', 'Anzahl'],
|
||||
'data' => $groups->map(fn ($participants, $name) => [$name, (string) count($participants)])->toArray(),
|
||||
'name' => 'Statistik',
|
||||
]));
|
||||
}
|
||||
|
||||
return $document;
|
||||
}
|
||||
|
||||
private function tempPath(): string
|
||||
{
|
||||
return sys_get_temp_dir() . '/' . str()->uuid()->toString();
|
||||
}
|
||||
}
|
|
@ -15,22 +15,14 @@ class ExportAction
|
|||
|
||||
public function handle(Form $form): string
|
||||
{
|
||||
$csv = Writer::createFromString();
|
||||
|
||||
$csv->insertOne($form->getFields()->names());
|
||||
|
||||
foreach ($form->participants as $participant) {
|
||||
$csv->insertOne($participant->getFields()->presentValues());
|
||||
}
|
||||
|
||||
return $csv->toString();
|
||||
return CreateExcelDocumentAction::run($form, $form->participants);
|
||||
}
|
||||
|
||||
public function asController(Form $form, ActionRequest $request): StreamedResponse
|
||||
{
|
||||
$contents = $this->handle($form);
|
||||
|
||||
$filename = 'tn-' . $form->slug . '.csv';
|
||||
$filename = 'tn-' . $form->slug . '.xlsx';
|
||||
Storage::disk('temp')->put($filename, $contents);
|
||||
|
||||
return Storage::disk('temp')->download($filename);
|
||||
|
|
|
@ -3,12 +3,8 @@
|
|||
namespace App\Form\Actions;
|
||||
|
||||
use App\Form\Models\Form;
|
||||
use App\Form\Models\Participant;
|
||||
use App\Group;
|
||||
use Illuminate\Support\Collection;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
use Zoomyboy\TableDocument\SheetData;
|
||||
use Zoomyboy\TableDocument\TableDocumentData;
|
||||
|
||||
class ExportSyncAction
|
||||
{
|
||||
|
@ -18,15 +14,13 @@ class ExportSyncAction
|
|||
|
||||
public function handle(Form $form): void
|
||||
{
|
||||
$this->form = $form;
|
||||
|
||||
if (!$form->export->root) {
|
||||
return;
|
||||
}
|
||||
|
||||
$storage = $form->export->root->getStorage();
|
||||
|
||||
$storage->put($form->export->root->resource . '/Anmeldungen ' . $form->name . '.xlsx', file_get_contents($this->allSheet($this->form->participants)->compile($this->tempPath())));
|
||||
$storage->put($form->export->root->resource . '/Anmeldungen ' . $form->name . '.xlsx', CreateExcelDocumentAction::run($form, $form->participants));
|
||||
|
||||
if ($form->export->toGroupField) {
|
||||
foreach ($form->participants->groupBy(fn ($participant) => $participant->data[$form->export->toGroupField]) as $groupId => $participants) {
|
||||
|
@ -35,7 +29,7 @@ class ExportSyncAction
|
|||
continue;
|
||||
}
|
||||
|
||||
$group->fileshare->getStorage()->put($group->fileshare->resource . '/Anmeldungen ' . $form->name . '.xlsx', file_get_contents($this->allSheet($participants)->compile($this->tempPath())));
|
||||
$group->fileshare->getStorage()->put($group->fileshare->resource . '/Anmeldungen ' . $form->name . '.xlsx', CreateExcelDocumentAction::run($form, $participants));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,48 +38,4 @@ class ExportSyncAction
|
|||
{
|
||||
$this->handle(Form::find($formId));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection<int, Participant> $participants
|
||||
*/
|
||||
private function allSheet(Collection $participants): TableDocumentData
|
||||
{
|
||||
$document = TableDocumentData::from(['title' => 'Anmeldungen für ' . $this->form->name, 'sheets' => []]);
|
||||
$headers = $this->form->getFields()->map(fn ($field) => $field->name)->toArray();
|
||||
|
||||
$document->addSheet(SheetData::from([
|
||||
'header' => $headers,
|
||||
'data' => $participants
|
||||
->map(fn ($participant) => $this->form->getFields()->map(fn ($field) => $participant->getFields()->find($field)->presentRaw())->toArray())
|
||||
->toArray(),
|
||||
'name' => 'Alle',
|
||||
]));
|
||||
|
||||
if ($this->form->export->groupBy) {
|
||||
$groups = $participants->groupBy(fn ($participant) => $participant->getFields()->findByKey($this->form->export->groupBy)->presentRaw());
|
||||
|
||||
foreach ($groups as $name => $participants) {
|
||||
$document->addSheet(SheetData::from([
|
||||
'header' => $headers,
|
||||
'data' => $participants
|
||||
->map(fn ($participant) => $this->form->getFields()->map(fn ($field) => $participant->getFields()->find($field)->presentRaw())->toArray())
|
||||
->toArray(),
|
||||
'name' => $name,
|
||||
]));
|
||||
}
|
||||
|
||||
$document->addSheet(SheetData::from([
|
||||
'header' => ['Wert', 'Anzahl'],
|
||||
'data' => $groups->map(fn ($participants, $name) => [$name, (string) count($participants)])->toArray(),
|
||||
'name' => 'Statistik',
|
||||
]));
|
||||
}
|
||||
|
||||
return $document;
|
||||
}
|
||||
|
||||
private function tempPath(): string
|
||||
{
|
||||
return sys_get_temp_dir() . '/' . str()->uuid()->toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class FormApiListAction
|
|||
|
||||
/**
|
||||
* @param string $filter
|
||||
* @return LengthAwarePaginator<Form>
|
||||
* @return LengthAwarePaginator<int, Form>
|
||||
*/
|
||||
public function handle(string $filter, int $perPage): LengthAwarePaginator
|
||||
{
|
||||
|
@ -27,7 +27,7 @@ class FormApiListAction
|
|||
{
|
||||
return FormApiResource::collection($this->handle(
|
||||
$request->input('filter', ''),
|
||||
$request->input('perPage', 10)
|
||||
$request->input('perPage', 9999)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace App\Form\Actions;
|
||||
|
||||
use App\Form\Models\Form;
|
||||
use App\Lib\Events\Succeeded;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class FormCopyAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
public function handle(Form $form): Form
|
||||
{
|
||||
$newForm = $form->replicate();
|
||||
$newForm->save();
|
||||
$newForm->update(['name' => $form->name.' - Kopie', 'is_active' => false]);
|
||||
|
||||
foreach ($form->getRegisteredMediaCollections() as $collection) {
|
||||
foreach ($form->getMedia($collection->name) as $media) {
|
||||
$media->copy($newForm, $collection->name);
|
||||
}
|
||||
}
|
||||
|
||||
ClearFrontendCacheAction::run();
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function asController(Form $form): JsonResponse
|
||||
{
|
||||
$this->handle($form);
|
||||
|
||||
Succeeded::message('Veranstaltung kopiert.')->dispatch();
|
||||
return response()->json([]);
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@ class FormIndexAction
|
|||
use AsAction;
|
||||
|
||||
/**
|
||||
* @return LengthAwarePaginator<Form>
|
||||
* @return LengthAwarePaginator<int, Form>
|
||||
*/
|
||||
public function handle(string $filter): LengthAwarePaginator
|
||||
{
|
||||
|
|
|
@ -36,6 +36,10 @@ class FormStoreAction
|
|||
'needs_prevention' => 'present|boolean',
|
||||
'prevention_text' => 'array',
|
||||
'prevention_conditions' => 'array',
|
||||
'leader_conditions' => 'array',
|
||||
'zip' => 'present|nullable|string',
|
||||
'location' => 'present|nullable|string',
|
||||
'country' => 'nullable|string|max:255',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Form\Actions;
|
||||
|
||||
use App\Form\Models\Form;
|
||||
use App\Lib\Editor\Condition;
|
||||
use App\Lib\Events\Succeeded;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
@ -36,6 +35,10 @@ class FormUpdateAction
|
|||
'needs_prevention' => 'present|boolean',
|
||||
'prevention_text' => 'array',
|
||||
'prevention_conditions' => 'array',
|
||||
'location' => 'present|nullable|string',
|
||||
'zip' => 'present|nullable|string',
|
||||
'country' => 'nullable|string|max:255',
|
||||
'leader_conditions' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -22,10 +22,10 @@ class FormUpdateMetaAction
|
|||
|
||||
return [
|
||||
'sorting' => 'array',
|
||||
'sorting.0' => 'required|string',
|
||||
'sorting.1' => 'required|string|in:asc,desc',
|
||||
'sorting.by' => 'required|string',
|
||||
'sorting.direction' => 'required|boolean',
|
||||
'active_columns' => 'array',
|
||||
'active_columns.*' => ['string', Rule::in([...$form->getFields()->pluck('key')->toArray(), 'created_at'])]
|
||||
'active_columns.*' => ['string', Rule::in([...$form->getFields()->pluck('key')->toArray(), 'created_at', 'prevention'])]
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ class FormtemplateIndexAction
|
|||
use AsAction;
|
||||
|
||||
/**
|
||||
* @return LengthAwarePaginator<Formtemplate>
|
||||
* @return LengthAwarePaginator<int, Formtemplate>
|
||||
*/
|
||||
public function handle(): LengthAwarePaginator
|
||||
{
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace App\Form\Actions;
|
||||
|
||||
use App\Contribution\Contracts\HasContributionData;
|
||||
use App\Contribution\ContributionFactory;
|
||||
use App\Form\Models\Form;
|
||||
use App\Form\Requests\FormCompileRequest;
|
||||
use App\Rules\JsonBase64Rule;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
use Zoomyboy\Tex\BaseCompiler;
|
||||
use Zoomyboy\Tex\Tex;
|
||||
|
||||
class GenerateContributionAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
public function handle(HasContributionData $request): BaseCompiler
|
||||
{
|
||||
return Tex::compile($request->type()::fromPayload($request));
|
||||
}
|
||||
|
||||
public function asController(ActionRequest $request, Form $form): BaseCompiler|JsonResponse
|
||||
{
|
||||
$r = FormCompileRequest::from(['form' => $form]);
|
||||
app(ContributionFactory::class)->validateType($r);
|
||||
$r->validateContribution();
|
||||
|
||||
return $request->input('validate')
|
||||
? response()->json([])
|
||||
: $this->handle($r);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'payload' => [new JsonBase64Rule()],
|
||||
];
|
||||
}
|
||||
}
|
|
@ -6,9 +6,8 @@ use App\Form\Models\Form;
|
|||
use App\Form\Models\Participant;
|
||||
use App\Form\Resources\ParticipantResource;
|
||||
use App\Form\Scopes\ParticipantFilterScope;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Laravel\Scout\Builder;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class ParticipantIndexAction
|
||||
|
@ -16,29 +15,22 @@ class ParticipantIndexAction
|
|||
use AsAction;
|
||||
|
||||
/**
|
||||
* @return HasMany<Participant>
|
||||
* @return Builder<Participant>
|
||||
*/
|
||||
protected function getQuery(Form $form, ParticipantFilterScope $filter): HasMany
|
||||
protected function getQuery(Form $form, ParticipantFilterScope $filter): Builder
|
||||
{
|
||||
return $form->participants()->withFilter($filter)->withCount('children')->with('form');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return LengthAwarePaginator<Participant>
|
||||
*/
|
||||
public function handle(Form $form, ParticipantFilterScope $filter): LengthAwarePaginator
|
||||
{
|
||||
return $this->getQuery($form, $filter)->paginate(15);
|
||||
return $filter->setForm($form)->getQuery()
|
||||
->query(fn ($q) => $q->withCount('children')->with('form'));
|
||||
}
|
||||
|
||||
public function asController(Form $form, ?int $parent = null): AnonymousResourceCollection
|
||||
{
|
||||
$filter = ParticipantFilterScope::fromRequest(request()->input('filter'));
|
||||
$filter = ParticipantFilterScope::fromRequest(request()->input('filter', ''))->parent($parent);
|
||||
|
||||
$data = match ($parent) {
|
||||
null => $this->handle($form, $filter),
|
||||
-1 => $this->getQuery($form, $filter)->where('parent_id', null)->paginate(15),
|
||||
default => $this->getQuery($form, $filter)->where('parent_id', $parent)->get(),
|
||||
null => $this->getQuery($form, $filter)->paginate(15), // initial all elements - paginate
|
||||
-1 => $this->getQuery($form, $filter)->paginate(15), // initial root elements - parinate
|
||||
default => $this->getQuery($form, $filter)->get(), // specific parent element - show all
|
||||
};
|
||||
|
||||
return ParticipantResource::collection($data)->additional(['meta' => ParticipantResource::meta($form)]);
|
||||
|
|
|
@ -13,13 +13,18 @@ class PreventionRememberAction
|
|||
{
|
||||
use AsAction;
|
||||
|
||||
public string $commandSignature = 'prevention:remember';
|
||||
public string $commandSignature = 'prevention:remember-forms';
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$query = Participant::whereHas('form', fn ($form) => $form->where('needs_prevention', true))
|
||||
$query = Participant::whereHas(
|
||||
'form',
|
||||
fn($form) => $form
|
||||
->where('needs_prevention', true)
|
||||
->where('from', '>=', now())
|
||||
)
|
||||
->where(
|
||||
fn ($q) => $q
|
||||
fn($q) => $q
|
||||
->where('last_remembered_at', '<=', now()->subWeeks(2))
|
||||
->orWhereNull('last_remembered_at')
|
||||
);
|
||||
|
@ -28,7 +33,7 @@ class PreventionRememberAction
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($participant->getFields()->getMailRecipient() === null || count($participant->preventions()) === 0) {
|
||||
if ($participant->getFields()->getMailRecipient() === null || $participant->preventions()->count() === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -36,7 +41,7 @@ class PreventionRememberAction
|
|||
->placeholder('formname', $participant->form->name)
|
||||
->append($participant->form->prevention_text);
|
||||
|
||||
Mail::send(new PreventionRememberMail($participant, $body));
|
||||
Mail::send(new PreventionRememberMail($participant, $body, $participant->preventions()));
|
||||
|
||||
$participant->update(['last_remembered_at' => now()]);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,9 @@ use App\Form\Models\Form;
|
|||
use App\Form\Models\Participant;
|
||||
use App\Member\Member;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
|
@ -21,7 +24,7 @@ class RegisterAction
|
|||
{
|
||||
$memberQuery = FieldCollection::fromRequest($form, $input)
|
||||
->withNamiType()
|
||||
->reduce(fn ($query, $field) => $field->namiType->performQuery($query, $field->value), (new Member())->newQuery());
|
||||
->reduce(fn($query, $field) => $field->namiType->performQuery($query, $field->value), (new Member())->newQuery());
|
||||
$member = $form->getFields()->withNamiType()->count() && $memberQuery->count() === 1 ? $memberQuery->first() : null;
|
||||
|
||||
$participant = $form->participants()->create([
|
||||
|
@ -29,7 +32,7 @@ class RegisterAction
|
|||
'member_id' => $member?->id,
|
||||
]);
|
||||
|
||||
$form->getFields()->each(fn ($field) => $field->afterRegistration($form, $participant, $input));
|
||||
$form->getFields()->each(fn($field) => $field->afterRegistration($form, $participant, $input));
|
||||
|
||||
$participant->sendConfirmationMail();
|
||||
ExportSyncAction::dispatch($form->id);
|
||||
|
@ -72,8 +75,26 @@ class RegisterAction
|
|||
|
||||
public function asController(ActionRequest $request, Form $form): JsonResponse
|
||||
{
|
||||
if (!$form->canRegister() && !$this->isRegisteringLater($request)) {
|
||||
throw ValidationException::withMessages(['event' => 'Anmeldung zzt nicht möglich.']);
|
||||
}
|
||||
|
||||
$participant = $this->handle($form, $request->validated());
|
||||
|
||||
return response()->json($participant);
|
||||
}
|
||||
|
||||
public function isRegisteringLater(ActionRequest $request): bool {
|
||||
if (!is_array($request->query())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$validator = Validator::make($request->query(), [
|
||||
'later' => 'required|numeric|in:1',
|
||||
'id' => 'required|string|uuid:4',
|
||||
'signature' => 'required|string',
|
||||
]);
|
||||
|
||||
return URL::hasValidSignature($request) && $validator->passes();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Form\Actions;
|
||||
|
||||
use App\Form\FormSettings;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class SettingIndexAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function handle(FormSettings $settings): array
|
||||
{
|
||||
return [
|
||||
'data' => [
|
||||
'register_url' => $settings->registerUrl,
|
||||
'clear_cache_url' => $settings->clearCacheUrl,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function asController(FormSettings $settings): Response
|
||||
{
|
||||
session()->put('menu', 'setting');
|
||||
session()->put('title', 'Module');
|
||||
|
||||
return Inertia::render('setting/Form', [
|
||||
'data' => $this->handle($settings),
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Form\Actions;
|
||||
|
||||
use App\Form\FormSettings;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class SettingStoreAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*/
|
||||
public function handle(array $input): void
|
||||
{
|
||||
$settings = app(FormSettings::class);
|
||||
|
||||
$settings->fill([
|
||||
'registerUrl' => $input['register_url'],
|
||||
'clearCacheUrl' => $input['clear_cache_url'],
|
||||
]);
|
||||
|
||||
$settings->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'register_url' => 'present|string',
|
||||
'clear_cache_url' => 'present|string',
|
||||
];
|
||||
}
|
||||
|
||||
public function asController(ActionRequest $request): RedirectResponse
|
||||
{
|
||||
$this->handle($request->validated());
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Form\Actions;
|
||||
|
||||
use App\Form\Models\Form;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class UpdateParticipantSearchIndexAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
public function handle(Form $form): void
|
||||
{
|
||||
if (config('scout.driver') !== 'meilisearch') {
|
||||
return;
|
||||
}
|
||||
|
||||
$form->searchableUsing()->updateIndexSettings(
|
||||
$form->participantsSearchableAs(),
|
||||
[
|
||||
'filterableAttributes' => [...$form->getFields()->filterables()->getKeys(), 'parent-id'],
|
||||
'searchableAttributes' => $form->getFields()->searchables()->getKeys(),
|
||||
'sortableAttributes' => [...$form->getFields()->sortables()->getKeys(), 'id', 'created_at'],
|
||||
'displayedAttributes' => [...$form->getFields()->filterables()->getKeys(), ...$form->getFields()->searchables()->getKeys(), 'id'],
|
||||
'pagination' => [
|
||||
'maxTotalHits' => 1000000,
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ use App\Form\Fields\Field;
|
|||
use Illuminate\Support\Collection;
|
||||
use Spatie\LaravelData\Casts\Cast;
|
||||
use Spatie\LaravelData\Data;
|
||||
use Spatie\LaravelData\Support\Creation\CreationContext;
|
||||
use Spatie\LaravelData\Support\DataProperty;
|
||||
|
||||
class CollectionCast implements Cast
|
||||
|
@ -20,10 +21,9 @@ class CollectionCast implements Cast
|
|||
|
||||
/**
|
||||
* @param array<int, array<string, mixed>> $value
|
||||
* @param array<string, mixed> $context
|
||||
* @return Collection<int, Data>
|
||||
*/
|
||||
public function cast(DataProperty $property, mixed $value, array $context): mixed
|
||||
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): mixed
|
||||
{
|
||||
return collect($value)->map(fn ($item) => $this->target::from($item));
|
||||
}
|
||||
|
|
|
@ -5,16 +5,16 @@ namespace App\Form\Casts;
|
|||
use App\Form\Data\FieldCollection;
|
||||
use App\Form\Fields\Field;
|
||||
use Spatie\LaravelData\Casts\Cast;
|
||||
use Spatie\LaravelData\Support\Creation\CreationContext;
|
||||
use Spatie\LaravelData\Support\DataProperty;
|
||||
|
||||
class FieldCollectionCast implements Cast
|
||||
{
|
||||
/**
|
||||
* @param array<int, array<string, string>> $value
|
||||
* @param array<string, mixed> $context
|
||||
* @return FieldCollection
|
||||
*/
|
||||
public function cast(DataProperty $property, mixed $value, array $context): mixed
|
||||
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): mixed
|
||||
{
|
||||
return new FieldCollection(collect($value)->map(fn ($value) => Field::classFromType($value['type'])::from($value))->all());
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace App\Form\Contracts;
|
||||
|
||||
interface Filterable
|
||||
{
|
||||
/** @param mixed $value */
|
||||
public function filter($value): string;
|
||||
}
|
|
@ -3,11 +3,11 @@
|
|||
namespace App\Form\Data;
|
||||
|
||||
use App\Fileshare\Data\FileshareResourceData;
|
||||
use App\Form\Fields\Field;
|
||||
use Spatie\LaravelData\Attributes\MapInputName;
|
||||
use Spatie\LaravelData\Attributes\MapOutputName;
|
||||
use Spatie\LaravelData\Data;
|
||||
use Spatie\LaravelData\Mappers\SnakeCaseMapper;
|
||||
use Spatie\LaravelData\Support\EloquentCasts\DataEloquentCast;
|
||||
|
||||
#[MapInputName(SnakeCaseMapper::class)]
|
||||
#[MapOutputName(SnakeCaseMapper::class)]
|
||||
|
@ -16,4 +16,13 @@ class ExportData extends Data
|
|||
public function __construct(public ?FileshareResourceData $root = null, public ?string $groupBy = null, public ?string $toGroupField = null)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, mixed> $arguments
|
||||
* @return DataEloquentCast<self>
|
||||
*/
|
||||
public static function castUsing(array $arguments): DataEloquentCast
|
||||
{
|
||||
return new DataEloquentCast(static::class, $arguments);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Form\Data;
|
||||
|
||||
use App\Form\Contracts\Filterable;
|
||||
use App\Form\Enums\SpecialType;
|
||||
use App\Form\Fields\Field;
|
||||
use App\Form\Fields\NamiField;
|
||||
|
@ -113,8 +114,36 @@ class FieldCollection extends Collection
|
|||
return $this->map(fn ($field) => $field->presentRaw())->toArray();
|
||||
}
|
||||
|
||||
private function findBySpecialType(SpecialType $specialType): ?Field
|
||||
public function hasSpecialType(SpecialType $specialType): bool
|
||||
{
|
||||
return $this->findBySpecialType($specialType) !== null;
|
||||
}
|
||||
|
||||
public function findBySpecialType(SpecialType $specialType): ?Field
|
||||
{
|
||||
return $this->first(fn ($field) => $field->specialType === $specialType);
|
||||
}
|
||||
|
||||
public function searchables(): self
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function sortables(): self
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function filterables(): self
|
||||
{
|
||||
return $this->filter(fn ($field) => $field instanceof Filterable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function getKeys(): array
|
||||
{
|
||||
return $this->map(fn ($field) => $field->key)->toArray();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ use Illuminate\Support\Collection;
|
|||
use Spatie\LaravelData\Data;
|
||||
use Spatie\LaravelData\Attributes\WithCast;
|
||||
use Spatie\LaravelData\Attributes\WithTransformer;
|
||||
use Spatie\LaravelData\Support\EloquentCasts\DataEloquentCast;
|
||||
|
||||
class FormConfigData extends Data
|
||||
{
|
||||
|
@ -29,4 +30,13 @@ class FormConfigData extends Data
|
|||
new FieldCollection([])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, mixed> $arguments
|
||||
* @return DataEloquentCast<self>
|
||||
*/
|
||||
public static function castUsing(array $arguments): DataEloquentCast
|
||||
{
|
||||
return new DataEloquentCast(static::class, $arguments);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ enum NamiType: string
|
|||
static::LOCATION => $member->location,
|
||||
static::NICKNAME => $member->nickname,
|
||||
static::GENDER => $member->gender?->name,
|
||||
static::AGE => $member->birthday->diffInYears(now()),
|
||||
static::AGE => intVal($member->birthday->diffInYears(now())),
|
||||
static::AGEEVENT => $member->birthday->diffInYears($form->from),
|
||||
static::MOBILEPHONE => $member->mobile_phone,
|
||||
};
|
||||
|
|
|
@ -7,6 +7,11 @@ enum SpecialType: string
|
|||
case FIRSTNAME = 'Vorname';
|
||||
case LASTNAME = 'Nachname';
|
||||
case EMAIL = 'E-Mail-Adresse';
|
||||
case BIRTHDAY = 'Geburtsdatum';
|
||||
case ZIP = 'PLZ';
|
||||
case LOCATION = 'Ort';
|
||||
case ADDRESS = 'Adresse';
|
||||
case GENDER = 'Geschlecht';
|
||||
|
||||
/**
|
||||
* @return array<int, array{name: string, id: string}>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Form\Fields;
|
||||
|
||||
use App\Form\Contracts\Filterable;
|
||||
use App\Form\Matchers\BooleanMatcher;
|
||||
use App\Form\Matchers\Matcher;
|
||||
use App\Form\Models\Form;
|
||||
|
@ -9,9 +10,8 @@ use App\Form\Models\Participant;
|
|||
use App\Form\Presenters\BooleanPresenter;
|
||||
use App\Form\Presenters\Presenter;
|
||||
use Faker\Generator;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CheckboxField extends Field
|
||||
class CheckboxField extends Field implements Filterable
|
||||
{
|
||||
public bool $required;
|
||||
public string $description;
|
||||
|
@ -86,4 +86,11 @@ class CheckboxField extends Field
|
|||
{
|
||||
return app(BooleanMatcher::class);
|
||||
}
|
||||
|
||||
public function filter($value): string
|
||||
{
|
||||
$asString = $value ? 'true' : 'false';
|
||||
|
||||
return "{$this->key} = $asString";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Form\Fields;
|
||||
|
||||
use App\Form\Contracts\Filterable;
|
||||
use App\Form\Matchers\Matcher;
|
||||
use App\Form\Matchers\SingleValueMatcher;
|
||||
use App\Form\Models\Form;
|
||||
|
@ -9,7 +10,7 @@ use App\Form\Models\Participant;
|
|||
use Faker\Generator;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class DropdownField extends Field
|
||||
class DropdownField extends Field implements Filterable
|
||||
{
|
||||
public bool $required;
|
||||
/** @var array<int, string> */
|
||||
|
@ -87,4 +88,14 @@ class DropdownField extends Field
|
|||
{
|
||||
return app(SingleValueMatcher::class);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function filter($value): string
|
||||
{
|
||||
if (is_null($value)) {
|
||||
return "{$this->key} IS NULL";
|
||||
}
|
||||
|
||||
return $this->key . ' = \'' . $value . '\'';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,4 +180,10 @@ abstract class Field extends Data
|
|||
{
|
||||
return app(SingleValueMatcher::class);
|
||||
}
|
||||
|
||||
/** @param mixed $value */
|
||||
public function filter($value): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Form\Fields;
|
||||
|
||||
use App\Form\Contracts\Filterable;
|
||||
use App\Form\Matchers\Matcher;
|
||||
use App\Form\Matchers\SingleValueMatcher;
|
||||
use App\Form\Models\Form;
|
||||
|
@ -9,7 +10,7 @@ use App\Form\Models\Participant;
|
|||
use Faker\Generator;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class RadioField extends Field
|
||||
class RadioField extends Field implements Filterable
|
||||
{
|
||||
public bool $required;
|
||||
/** @var array<int, string> */
|
||||
|
@ -87,4 +88,13 @@ class RadioField extends Field
|
|||
{
|
||||
return app(SingleValueMatcher::class);
|
||||
}
|
||||
|
||||
public function filter($value): string
|
||||
{
|
||||
if (is_null($value)) {
|
||||
return "{$this->key} IS NULL";
|
||||
}
|
||||
|
||||
return $this->key . ' = \'' . $value . '\'';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,13 +2,12 @@
|
|||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Form\Actions\SettingIndexAction;
|
||||
use App\Form\Actions\SettingStoreAction;
|
||||
use App\Setting\Contracts\Indexable;
|
||||
use App\Setting\Contracts\Storeable;
|
||||
use App\Setting\LocalSettings;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
|
||||
class FormSettings extends LocalSettings implements Indexable, Storeable
|
||||
class FormSettings extends LocalSettings implements Storeable
|
||||
{
|
||||
public string $registerUrl;
|
||||
public string $clearCacheUrl;
|
||||
|
@ -18,23 +17,38 @@ class FormSettings extends LocalSettings implements Indexable, Storeable
|
|||
return 'form';
|
||||
}
|
||||
|
||||
public static function slug(): string
|
||||
{
|
||||
return 'form';
|
||||
}
|
||||
|
||||
public static function title(): string
|
||||
{
|
||||
return 'Formulare';
|
||||
}
|
||||
|
||||
public static function indexAction(): string
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return SettingIndexAction::class;
|
||||
return [
|
||||
'registerUrl' => 'present|string',
|
||||
'clearCacheUrl' => 'present|string',
|
||||
];
|
||||
}
|
||||
|
||||
public static function storeAction(): string
|
||||
public function beforeSave(ActionRequest $request): void
|
||||
{
|
||||
return SettingStoreAction::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function viewData(): array
|
||||
{
|
||||
return [
|
||||
'data' => [
|
||||
'data' => [
|
||||
'registerUrl' => $this->registerUrl,
|
||||
'clearCacheUrl' => $this->clearCacheUrl,
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,10 +69,8 @@ class ConfirmRegistrationMail extends Mailable
|
|||
*/
|
||||
public function attachments()
|
||||
{
|
||||
$conditionResolver = app(FormConditionResolver::class)->forParticipant($this->participant);
|
||||
|
||||
return $this->participant->form->getMedia('mailattachments')
|
||||
->filter(fn ($media) => $conditionResolver->filterCondition(Condition::fromMedia($media)))
|
||||
->filter(fn ($media) => $this->participant->matchesCondition(Condition::fromMedia($media)))
|
||||
->map(fn ($media) => Attachment::fromStorageDisk($media->disk, $media->getPathRelativeToRoot()))
|
||||
->all();
|
||||
}
|
||||
|
|
|
@ -2,25 +2,29 @@
|
|||
|
||||
namespace App\Form\Models;
|
||||
|
||||
use App\Contribution\Enums\Country;
|
||||
use App\Form\Actions\UpdateParticipantSearchIndexAction;
|
||||
use App\Form\Data\ExportData;
|
||||
use App\Form\Data\FieldCollection;
|
||||
use App\Form\Data\FormConfigData;
|
||||
use App\Lib\Editor\Condition;
|
||||
use App\Lib\Editor\EditorData;
|
||||
use App\Lib\Sorting;
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Database\Factories\Form\Models\FormFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Laravel\Scout\Searchable;
|
||||
use Spatie\Image\Manipulations;
|
||||
use Spatie\Image\Enums\Fit;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
use Zoomyboy\MedialibraryHelper\DefersUploads;
|
||||
|
||||
/** @todo replace editor content with EditorData cast */
|
||||
class Form extends Model implements HasMedia
|
||||
{
|
||||
/** @use HasFactory<FormFactory> */
|
||||
use HasFactory;
|
||||
use Sluggable;
|
||||
use InteractsWithMedia;
|
||||
|
@ -41,11 +45,14 @@ class Form extends Model implements HasMedia
|
|||
'needs_prevention' => 'boolean',
|
||||
'prevention_text' => EditorData::class,
|
||||
'prevention_conditions' => Condition::class,
|
||||
'from' => 'datetime',
|
||||
'to' => 'datetime',
|
||||
'registration_from' => 'datetime',
|
||||
'registration_until' => 'datetime',
|
||||
'country' => Country::class,
|
||||
'leader_conditions' => Condition::class,
|
||||
];
|
||||
|
||||
/** @var array<int, string> */
|
||||
public $dates = ['from', 'to', 'registration_from', 'registration_until'];
|
||||
|
||||
/**
|
||||
* @return SluggableConfig
|
||||
*/
|
||||
|
@ -57,32 +64,31 @@ class Form extends Model implements HasMedia
|
|||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<Participant>
|
||||
* @return HasMany<Participant, $this>
|
||||
*/
|
||||
public function participants(): HasMany
|
||||
{
|
||||
return $this->hasMany(Participant::class);
|
||||
}
|
||||
|
||||
|
||||
public function registerMediaCollections(): void
|
||||
{
|
||||
$this->addMediaCollection('headerImage')
|
||||
->singleFile()
|
||||
->maxWidth(fn () => 500)
|
||||
->forceFileName(fn (Form $model, string $name) => $model->slug)
|
||||
->convert(fn () => 'jpg')
|
||||
->registerMediaConversions(function (Media $media) {
|
||||
$this->addMediaConversion('square')->fit(Manipulations::FIT_CROP, 400, 400);
|
||||
->maxWidth(fn() => 500)
|
||||
->forceFileName(fn(Form $model) => $model->slug)
|
||||
->convert(fn() => 'jpg')
|
||||
->registerMediaConversions(function () {
|
||||
$this->addMediaConversion('square')->fit(Fit::Crop, 400, 400);
|
||||
});
|
||||
$this->addMediaCollection('mailattachments')
|
||||
->withDefaultProperties(fn () => [
|
||||
->withDefaultProperties(fn() => [
|
||||
'conditions' => [
|
||||
'mode' => 'all',
|
||||
'ifs' => []
|
||||
],
|
||||
])
|
||||
->withPropertyValidation(fn () => [
|
||||
->withPropertyValidation(fn() => [
|
||||
'conditions.mode' => 'required|string|in:all,any',
|
||||
'conditions.ifs' => 'array',
|
||||
'conditions.ifs.*.field' => 'required',
|
||||
|
@ -96,7 +102,7 @@ class Form extends Model implements HasMedia
|
|||
*/
|
||||
public function getRegistrationRules(): array
|
||||
{
|
||||
return $this->getFields()->reduce(fn ($carry, $field) => [
|
||||
return $this->getFields()->reduce(fn($carry, $field) => [
|
||||
...$carry,
|
||||
...$field->getRegistrationRules($this),
|
||||
], []);
|
||||
|
@ -107,7 +113,7 @@ class Form extends Model implements HasMedia
|
|||
*/
|
||||
public function getRegistrationMessages(): array
|
||||
{
|
||||
return $this->getFields()->reduce(fn ($carry, $field) => [
|
||||
return $this->getFields()->reduce(fn($carry, $field) => [
|
||||
...$carry,
|
||||
...$field->getRegistrationMessages($this),
|
||||
], []);
|
||||
|
@ -118,7 +124,7 @@ class Form extends Model implements HasMedia
|
|||
*/
|
||||
public function getRegistrationAttributes(): array
|
||||
{
|
||||
return $this->getFields()->reduce(fn ($carry, $field) => [
|
||||
return $this->getFields()->reduce(fn($carry, $field) => [
|
||||
...$carry,
|
||||
...$field->getRegistrationAttributes($this),
|
||||
], []);
|
||||
|
@ -155,7 +161,7 @@ class Form extends Model implements HasMedia
|
|||
if (is_null(data_get($model->meta, 'active_columns'))) {
|
||||
$model->setAttribute('meta', [
|
||||
'active_columns' => $model->getFields()->count() ? $model->getFields()->take(4)->pluck('key')->toArray() : null,
|
||||
'sorting' => $model->getFields()->count() ? [$model->getFields()->first()->key, 'asc'] : null,
|
||||
'sorting' => Sorting::by('id'),
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
@ -163,10 +169,41 @@ class Form extends Model implements HasMedia
|
|||
if (is_array(data_get($model->meta, 'active_columns'))) {
|
||||
$model->setAttribute('meta', [
|
||||
...$model->meta,
|
||||
'active_columns' => array_values(array_intersect([...$model->getFields()->pluck('key')->toArray(), 'created_at'], $model->meta['active_columns'])),
|
||||
'active_columns' => array_values(array_intersect([...$model->getFields()->pluck('key')->toArray(), 'created_at', 'prevention'], $model->meta['active_columns'])),
|
||||
]);
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
static::saved(function ($model) {
|
||||
UpdateParticipantSearchIndexAction::dispatch($model);
|
||||
});
|
||||
}
|
||||
|
||||
public function participantsSearchableAs(): string
|
||||
{
|
||||
return config('scout.prefix') . 'forms_' . $this->id . '_participants';
|
||||
}
|
||||
|
||||
public function defaultSorting(): Sorting
|
||||
{
|
||||
return Sorting::from($this->meta['sorting']);
|
||||
}
|
||||
|
||||
public function isInDates(): bool {
|
||||
if ($this->registration_from && $this->registration_from->gt(now())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->registration_until && $this->registration_until->lt(now())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canRegister(): bool
|
||||
{
|
||||
return $this->is_active && $this->isInDates();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Form\Models;
|
|||
|
||||
use App\Form\Data\FormConfigData;
|
||||
use App\Lib\Editor\EditorData;
|
||||
use Database\Factories\Form\Models\FormtemplateFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
|
@ -12,6 +13,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
*/
|
||||
class Formtemplate extends Model
|
||||
{
|
||||
/** @use HasFactory<FormtemplateFactory> */
|
||||
use HasFactory;
|
||||
|
||||
public $guarded = [];
|
||||
|
|
|
@ -4,21 +4,27 @@ namespace App\Form\Models;
|
|||
|
||||
use App\Form\Data\FieldCollection;
|
||||
use App\Form\Data\FormConfigData;
|
||||
use App\Form\Editor\FormConditionResolver;
|
||||
use App\Form\Mails\ConfirmRegistrationMail;
|
||||
use App\Form\Scopes\ParticipantFilterScope;
|
||||
use App\Lib\Editor\Condition;
|
||||
use App\Member\Member;
|
||||
use App\Prevention\Contracts\Preventable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Database\Factories\Form\Models\ParticipantFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Laravel\Scout\Searchable;
|
||||
use stdClass;
|
||||
|
||||
class Participant extends Model implements Preventable
|
||||
{
|
||||
|
||||
/** @use HasFactory<ParticipantFactory> */
|
||||
use HasFactory;
|
||||
use Searchable;
|
||||
|
||||
public $guarded = [];
|
||||
|
||||
|
@ -28,7 +34,7 @@ class Participant extends Model implements Preventable
|
|||
];
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Form, self>
|
||||
* @return BelongsTo<Form, $this>
|
||||
*/
|
||||
public function form(): BelongsTo
|
||||
{
|
||||
|
@ -36,7 +42,7 @@ class Participant extends Model implements Preventable
|
|||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<self>
|
||||
* @return HasMany<Participant, $this>
|
||||
*/
|
||||
public function children(): HasMany
|
||||
{
|
||||
|
@ -44,16 +50,7 @@ class Participant extends Model implements Preventable
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Builder<self> $query
|
||||
* @return Builder<self>
|
||||
*/
|
||||
public function scopeWithFilter(Builder $query, ParticipantFilterScope $filter): Builder
|
||||
{
|
||||
return $filter->apply($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Member, self>
|
||||
* @return BelongsTo<Member, $this>
|
||||
*/
|
||||
public function member(): BelongsTo
|
||||
{
|
||||
|
@ -85,20 +82,15 @@ class Participant extends Model implements Preventable
|
|||
Mail::to($this->getMailRecipient())->queue(new ConfirmRegistrationMail($this));
|
||||
}
|
||||
|
||||
public function preventableLayout(): string
|
||||
{
|
||||
return 'mail.prevention.prevention-remember-participant';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function preventions(): array
|
||||
public function preventions(): Collection
|
||||
{
|
||||
return $this->member?->preventions($this->form->from) ?: [];
|
||||
return $this->member?->preventions($this->form->from) ?: collect([]);
|
||||
}
|
||||
|
||||
public function getMailRecipient(): stdClass
|
||||
public function getMailRecipient(): ?stdClass
|
||||
{
|
||||
return $this->getFields()->getMailRecipient();
|
||||
}
|
||||
|
@ -107,4 +99,19 @@ class Participant extends Model implements Preventable
|
|||
{
|
||||
return 'Nachweise erforderlich für deine Anmeldung zu ' . $this->form->name;
|
||||
}
|
||||
|
||||
public function searchableAs(): string
|
||||
{
|
||||
return $this->form->participantsSearchableAs();
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
public function toSearchableArray(): array
|
||||
{
|
||||
return [...$this->data, 'parent-id' => $this->parent_id, 'created_at' => $this->created_at->timestamp];
|
||||
}
|
||||
|
||||
public function matchesCondition(Condition $condition): bool {
|
||||
return app(FormConditionResolver::class)->forParticipant($this)->filterCondition($condition);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
|
||||
namespace App\Form\Requests;
|
||||
|
||||
use App\Contribution\Contracts\HasContributionData;
|
||||
use App\Contribution\Data\MemberData;
|
||||
use App\Contribution\Documents\ContributionDocument;
|
||||
use App\Country;
|
||||
use App\Form\Editor\FormConditionResolver;
|
||||
use App\Form\Enums\SpecialType;
|
||||
use App\Form\Models\Form;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class FormCompileRequest extends Data implements HasContributionData {
|
||||
|
||||
public function __construct(public Form $form) {}
|
||||
|
||||
/**
|
||||
* @return class-string<ContributionDocument>
|
||||
*/
|
||||
public function type(): string
|
||||
{
|
||||
$payload = json_decode(rawurldecode(base64_decode(request()->input('payload'))), true);
|
||||
|
||||
return $payload['type'];
|
||||
}
|
||||
|
||||
public function dateFrom(): Carbon
|
||||
{
|
||||
return $this->form->from;
|
||||
}
|
||||
|
||||
public function dateUntil(): Carbon
|
||||
{
|
||||
return $this->form->to;
|
||||
}
|
||||
|
||||
public function zipLocation(): string
|
||||
{
|
||||
return $this->form->zip.' '.$this->form->location;
|
||||
}
|
||||
|
||||
public function eventName(): string
|
||||
{
|
||||
return $this->form->name;
|
||||
}
|
||||
|
||||
public function members(): Collection
|
||||
{
|
||||
$members = [];
|
||||
$fields = [
|
||||
[SpecialType::FIRSTNAME, 'firstname'],
|
||||
[SpecialType::LASTNAME, 'lastname'],
|
||||
[SpecialType::BIRTHDAY, 'birthday'],
|
||||
[SpecialType::GENDER, 'gender'],
|
||||
[SpecialType::ADDRESS, 'address'],
|
||||
[SpecialType::ZIP, 'zip'],
|
||||
[SpecialType::LOCATION, 'location'],
|
||||
];
|
||||
|
||||
foreach ($this->form->participants as $participant) {
|
||||
$member = [];
|
||||
foreach ($fields as [$type, $name]) {
|
||||
$f = $this->form->getFields()->findBySpecialType($type);
|
||||
if (!$f) {
|
||||
continue;
|
||||
}
|
||||
$member[$name] = $participant->getFields()->find($f)->value;
|
||||
}
|
||||
|
||||
$members[] = [
|
||||
'is_leader' => $participant->matchesCondition($participant->form->leader_conditions),
|
||||
'gender' => 'weiblich',
|
||||
...$member,
|
||||
];
|
||||
}
|
||||
|
||||
return MemberData::fromApi($members);
|
||||
}
|
||||
|
||||
public function country(): ?Country
|
||||
{
|
||||
return Country::first();
|
||||
}
|
||||
|
||||
public function validateContribution(): void
|
||||
{
|
||||
Validator::make($this->form->toArray(), [
|
||||
'zip' => 'required',
|
||||
'location' => 'required'
|
||||
])
|
||||
->after(function($validator) {
|
||||
foreach ($this->type()::requiredFormSpecialTypes() as $type) {
|
||||
if (!$this->form->getFields()->hasSpecialType($type)) {
|
||||
$validator->errors()->add($type->name, 'Kein Feld für ' . $type->value . ' vorhanden.');
|
||||
}
|
||||
}
|
||||
if ($this->form->participants->count() === 0) {
|
||||
$validator->errors()->add('participants', 'Veranstaltung besitzt noch keine Teilnehmer*innen.');
|
||||
}
|
||||
})
|
||||
->validate();
|
||||
}
|
||||
}
|
|
@ -35,6 +35,7 @@ class FormApiResource extends JsonResource
|
|||
'image' => $this->getMedia('headerImage')->first()->getFullUrl('square'),
|
||||
'is_active' => $this->is_active,
|
||||
'is_private' => $this->is_private,
|
||||
'can_register' => $this->getModel()->canRegister(),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Form\Resources;
|
||||
|
||||
use App\Contribution\Enums\Country;
|
||||
use App\Form\Data\ExportData;
|
||||
use App\Form\Enums\NamiType;
|
||||
use App\Form\Enums\SpecialType;
|
||||
|
@ -14,6 +15,7 @@ use App\Group;
|
|||
use App\Lib\Editor\EditorData;
|
||||
use App\Lib\HasMeta;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Contribution\ContributionFactory;
|
||||
|
||||
/**
|
||||
* @mixin Form
|
||||
|
@ -44,6 +46,7 @@ class FormResource extends JsonResource
|
|||
'mail_bottom' => $this->mail_bottom,
|
||||
'registration_from' => $this->registration_from?->format('Y-m-d H:i:s'),
|
||||
'registration_until' => $this->registration_until?->format('Y-m-d H:i:s'),
|
||||
'is_in_dates' => $this->isInDates(),
|
||||
'config' => $this->config,
|
||||
'participants_count' => $this->participants_count,
|
||||
'is_active' => $this->is_active,
|
||||
|
@ -53,14 +56,20 @@ class FormResource extends JsonResource
|
|||
'needs_prevention' => $this->needs_prevention,
|
||||
'prevention_text' => $this->prevention_text,
|
||||
'prevention_conditions' => $this->prevention_conditions,
|
||||
'leader_conditions' => $this->leader_conditions,
|
||||
'zip' => $this->zip,
|
||||
'location' => $this->location,
|
||||
'country' => $this->country,
|
||||
'links' => [
|
||||
'participant_index' => route('form.participant.index', ['form' => $this->getModel(), 'parent' => null]),
|
||||
'participant_root_index' => route('form.participant.index', ['form' => $this->getModel(), 'parent' => -1]),
|
||||
'update' => route('form.update', ['form' => $this->getModel()]),
|
||||
'destroy' => route('form.destroy', ['form' => $this->getModel()]),
|
||||
'is_dirty' => route('form.is-dirty', ['form' => $this->getModel()]),
|
||||
'update' => route('form.update', $this->getModel()),
|
||||
'destroy' => route('form.destroy', $this->getModel()),
|
||||
'is_dirty' => route('form.is-dirty', $this->getModel()),
|
||||
'frontend' => str(app(FormSettings::class)->registerUrl)->replace('{slug}', $this->slug),
|
||||
'export' => route('form.export', ['form' => $this->getModel()]),
|
||||
'export' => route('form.export', $this->getModel()),
|
||||
'copy' => route('form.copy', $this->getModel()),
|
||||
'contribution' => route('form.contribution', $this->getModel()),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
@ -82,6 +91,8 @@ class FormResource extends JsonResource
|
|||
'templates' => FormtemplateResource::collection(Formtemplate::get()),
|
||||
'namiTypes' => NamiType::forSelect(),
|
||||
'specialTypes' => SpecialType::forSelect(),
|
||||
'countries' => Country::forSelect(),
|
||||
'contribution_types' => app(ContributionFactory::class)->compilerSelect(),
|
||||
'default' => [
|
||||
'description' => [],
|
||||
'is_active' => true,
|
||||
|
@ -101,6 +112,9 @@ class FormResource extends JsonResource
|
|||
'id' => null,
|
||||
'export' => ExportData::from([]),
|
||||
'prevention_conditions' => ['mode' => 'all', 'ifs' => []],
|
||||
'zip' => '',
|
||||
'location' => '',
|
||||
'country' => null,
|
||||
],
|
||||
'section_default' => [
|
||||
'name' => '',
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace App\Form\Resources;
|
|||
use App\Form\Models\Form;
|
||||
use App\Form\Models\Participant;
|
||||
use App\Form\Scopes\ParticipantFilterScope;
|
||||
use App\Prevention\Enums\Prevention;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
|
@ -28,6 +29,7 @@ class ParticipantResource extends JsonResource
|
|||
'created_at_display' => $this->created_at->format('d.m.Y'),
|
||||
'children_count' => $this->children_count,
|
||||
'member_id' => $this->member_id,
|
||||
'prevention_items' => $this->member ? Prevention::items($this->member->preventions()) : [],
|
||||
'links' => [
|
||||
'assign' => route('participant.assign', ['participant' => $this->getModel()]),
|
||||
'destroy' => route('participant.destroy', ['participant' => $this->getModel()]),
|
||||
|
@ -73,7 +75,11 @@ class ParticipantResource extends JsonResource
|
|||
'name' => 'Registriert am',
|
||||
'id' => 'created_at',
|
||||
'display_attribute' => 'created_at_display'
|
||||
])
|
||||
])->push([
|
||||
'name' => 'Prävention',
|
||||
'id' => 'prevention',
|
||||
'display_attribute' => 'prevention_display'
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,32 +4,76 @@ namespace App\Form\Scopes;
|
|||
|
||||
use App\Form\Models\Form;
|
||||
use App\Form\Models\Participant;
|
||||
use App\Lib\Filter;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Lib\ScoutFilter;
|
||||
use App\Lib\Sorting;
|
||||
use Illuminate\Support\Arr;
|
||||
use Laravel\Scout\Builder;
|
||||
use Spatie\LaravelData\Attributes\MapInputName;
|
||||
use Spatie\LaravelData\Attributes\MapOutputName;
|
||||
use Spatie\LaravelData\Mappers\SnakeCaseMapper;
|
||||
|
||||
/**
|
||||
* @extends Filter<Participant>
|
||||
* @extends ScoutFilter<Participant>
|
||||
*/
|
||||
#[MapInputName(SnakeCaseMapper::class)]
|
||||
#[MapOutputName(SnakeCaseMapper::class)]
|
||||
class ParticipantFilterScope extends Filter
|
||||
class ParticipantFilterScope extends ScoutFilter
|
||||
{
|
||||
|
||||
public static string $nan = 'deeb3ef4-d185-44b1-a4bc-0a4e7addebc3d8900c6f-a344-4afb-b54e-065ed483a7ba';
|
||||
private Form $form;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
* @param array<string, mixed> $options
|
||||
*/
|
||||
public function __construct(
|
||||
public array $data = [],
|
||||
public string $search = '',
|
||||
public array $options = [],
|
||||
public ?int $parent = null,
|
||||
public ?Sorting $sort = null
|
||||
) {
|
||||
}
|
||||
|
||||
public static string $nan = 'deeb3ef4-d185-44b1-a4bc-0a4e7addebc3d8900c6f-a344-4afb-b54e-065ed483a7ba';
|
||||
public function getQuery(): Builder
|
||||
{
|
||||
$this->search = $this->search ?: '';
|
||||
|
||||
return Participant::search($this->search, function ($engine, string $query, array $options) {
|
||||
$filter = collect([]);
|
||||
|
||||
foreach ($this->form->getFields()->filterables() as $field) {
|
||||
if ($this->data[$field->key] === static::$nan) {
|
||||
continue;
|
||||
}
|
||||
$filter->push($field->filter($this->data[$field->key]));
|
||||
}
|
||||
|
||||
if ($this->parent === -1) {
|
||||
$filter->push('parent-id IS NULL');
|
||||
}
|
||||
|
||||
if ($this->parent !== null && $this->parent !== -1) {
|
||||
$filter->push('parent-id = ' . $this->parent);
|
||||
}
|
||||
|
||||
$options['filter'] = $filter->map(fn ($expression) => "($expression)")->implode(' AND ');
|
||||
|
||||
$options['sort'] = $this->sort->toMeilisearch();
|
||||
|
||||
return $engine->search($query, [...$this->options, ...$options]);
|
||||
})->within($this->form->participantsSearchableAs());
|
||||
}
|
||||
|
||||
public function setForm(Form $form): self
|
||||
{
|
||||
$this->form = $form;
|
||||
|
||||
if (is_null($this->sort)) {
|
||||
$this->sort = $this->form->defaultSorting();
|
||||
}
|
||||
|
||||
foreach ($form->getFields() as $field) {
|
||||
if (!Arr::has($this->data, $field->key)) {
|
||||
data_set($this->data, $field->key, static::$nan);
|
||||
|
@ -39,18 +83,10 @@ class ParticipantFilterScope extends Filter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function apply(Builder $query): Builder
|
||||
public function parent(?int $parent): self
|
||||
{
|
||||
foreach ($this->data as $key => $value) {
|
||||
if ($value === static::$nan) {
|
||||
continue;
|
||||
}
|
||||
$query = $query->where('data->' . $key, $value);
|
||||
}
|
||||
$this->parent = $parent;
|
||||
|
||||
return $query;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace App\Form\Transformers;
|
|||
use App\Form\Fields\Field;
|
||||
use Illuminate\Support\Collection;
|
||||
use Spatie\LaravelData\Support\DataProperty;
|
||||
use Spatie\LaravelData\Support\Transformation\TransformationContext;
|
||||
use Spatie\LaravelData\Transformers\Transformer;
|
||||
|
||||
class CollectionTransformer implements Transformer
|
||||
|
@ -18,7 +19,7 @@ class CollectionTransformer implements Transformer
|
|||
* @param Collection<int, Field> $value
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function transform(DataProperty $property, mixed $value): mixed
|
||||
public function transform(DataProperty $property, mixed $value, TransformationContext $context): mixed
|
||||
{
|
||||
return $value->toArray();
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace App\Form\Transformers;
|
|||
use App\Form\Fields\Field;
|
||||
use Illuminate\Support\Collection;
|
||||
use Spatie\LaravelData\Support\DataProperty;
|
||||
use Spatie\LaravelData\Support\Transformation\TransformationContext;
|
||||
use Spatie\LaravelData\Transformers\Transformer;
|
||||
|
||||
class FieldCollectionTransformer implements Transformer
|
||||
|
@ -14,7 +15,7 @@ class FieldCollectionTransformer implements Transformer
|
|||
* @param Collection<int, Field> $value
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function transform(DataProperty $property, mixed $value): mixed
|
||||
public function transform(DataProperty $property, mixed $value, TransformationContext $context): mixed
|
||||
{
|
||||
return $value->map(fn ($field) => [
|
||||
...$field->toArray(),
|
||||
|
|
|
@ -3,12 +3,15 @@
|
|||
namespace App;
|
||||
|
||||
use App\Nami\HasNamiField;
|
||||
use Database\Factories\GenderFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Gender extends Model
|
||||
{
|
||||
use HasNamiField;
|
||||
|
||||
/** @use HasFactory<GenderFactory> */
|
||||
use HasFactory;
|
||||
|
||||
public $fillable = ['name', 'nami_id'];
|
||||
|
@ -22,6 +25,15 @@ class Gender extends Model
|
|||
};
|
||||
}
|
||||
|
||||
public function getShortAttribute(): string
|
||||
{
|
||||
return match ($this->name) {
|
||||
'Männlich' => 'm',
|
||||
'Weiblich' => 'w',
|
||||
default => ''
|
||||
};
|
||||
}
|
||||
|
||||
public static function fromString(string $title): self
|
||||
{
|
||||
return self::firstWhere('name', $title);
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace App;
|
|||
use App\Fileshare\Data\FileshareResourceData;
|
||||
use App\Group\Enums\Level;
|
||||
use App\Nami\HasNamiField;
|
||||
use Database\Factories\GroupFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
@ -12,6 +13,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||
|
||||
class Group extends Model
|
||||
{
|
||||
/** @use HasFactory<GroupFactory> */
|
||||
use HasFactory;
|
||||
use HasNamiField;
|
||||
|
||||
|
@ -24,19 +26,19 @@ class Group extends Model
|
|||
];
|
||||
|
||||
/**
|
||||
* @return BelongsTo<static, self>
|
||||
* @return BelongsTo<Group, $this>
|
||||
*/
|
||||
public function parent(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(static::class, 'parent_id');
|
||||
return $this->belongsTo(self::class, 'parent_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<self>
|
||||
* @return HasMany<Group, $this>
|
||||
*/
|
||||
public function children(): HasMany
|
||||
{
|
||||
return $this->hasMany(static::class, 'parent_id');
|
||||
return $this->hasMany(self::class, 'parent_id');
|
||||
}
|
||||
|
||||
public static function booted(): void
|
||||
|
|
|
@ -6,6 +6,7 @@ use App\Group;
|
|||
use App\Group\Resources\GroupResource;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class GroupApiIndexAction
|
||||
|
@ -20,8 +21,12 @@ class GroupApiIndexAction
|
|||
return Group::get();
|
||||
}
|
||||
|
||||
public function asController(?Group $group = null): AnonymousResourceCollection
|
||||
public function asController(ActionRequest $request, ?Group $group = null): AnonymousResourceCollection
|
||||
{
|
||||
return GroupResource::collection($group ? $group->children()->withCount('children')->get() : Group::where('parent_id', null)->withCount('children')->get());
|
||||
return GroupResource::collection(
|
||||
$request->has('all')
|
||||
? Group::with('children')->get()
|
||||
: ($group ? $group->children()->withCount('children')->get() : Group::where('parent_id', null)->withCount('children')->get())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,5 +18,7 @@ class Authenticate extends Middleware
|
|||
if (!$request->expectsJson()) {
|
||||
return route('login');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,9 @@ class UserResource extends JsonResource
|
|||
public function toArray($request): array
|
||||
{
|
||||
return [
|
||||
'name' => $this->name,
|
||||
'firstname' => $this->firstname,
|
||||
'lastname' => $this->lastname,
|
||||
'avatar_url' => $this->getGravatarUrl(),
|
||||
'email' => $this->email,
|
||||
'avatar' => [
|
||||
'src' => Storage::url('avatar.png'),
|
||||
|
|
|
@ -71,7 +71,7 @@ class InitializeAction
|
|||
|
||||
public function asController(ActionRequest $request, NamiSettings $settings): RedirectResponse
|
||||
{
|
||||
$settings->mglnr = (int) $request->input('mglnr');
|
||||
$settings->mglnr = $request->input('mglnr');
|
||||
$settings->password = $request->input('password');
|
||||
$settings->default_group_id = (int) $request->input('group_id');
|
||||
$settings->search_params = $request->input('params');
|
||||
|
|
|
@ -21,7 +21,7 @@ class NamiGetSearchLayerAction
|
|||
*/
|
||||
public function handle(array $input): Collection
|
||||
{
|
||||
return Nami::login((int) $input['mglnr'], $input['password'])->searchLayerOptions(
|
||||
return Nami::login($input['mglnr'], $input['password'])->searchLayerOptions(
|
||||
SearchLayer::from($input['layer'] ?: 0),
|
||||
$input['parent'] ?: null
|
||||
);
|
||||
|
|
|
@ -16,7 +16,7 @@ class NamiLoginCheckAction
|
|||
*/
|
||||
public function handle(array $input): void
|
||||
{
|
||||
Nami::freshLogin((int) $input['mglnr'], $input['password']);
|
||||
Nami::freshLogin($input['mglnr'], $input['password']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,7 +16,7 @@ class NamiSearchAction
|
|||
/**
|
||||
* @param array<string, mixed> $params
|
||||
*
|
||||
* @return LengthAwarePaginator<MemberEntry>
|
||||
* @return LengthAwarePaginator<int, MemberEntry>
|
||||
*/
|
||||
public function handle(Api $api, int $page, array $params, int $perPage = 10): LengthAwarePaginator
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ class NamiSearchAction
|
|||
}
|
||||
|
||||
/**
|
||||
* @return LengthAwarePaginator<MemberEntry>
|
||||
* @return LengthAwarePaginator<int, MemberEntry>
|
||||
*/
|
||||
public function asController(ActionRequest $request): LengthAwarePaginator
|
||||
{
|
||||
|
|
|
@ -6,9 +6,9 @@ use Lorisleiva\Actions\Concerns\AsAction;
|
|||
use App\Invoice\Models\Invoice;
|
||||
use App\Invoice\Resources\InvoiceResource;
|
||||
use App\Invoice\Scopes\InvoiceFilterScope;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
use Laravel\Scout\Builder;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
|
||||
class InvoiceIndexAction
|
||||
|
@ -17,11 +17,11 @@ class InvoiceIndexAction
|
|||
|
||||
|
||||
/**
|
||||
* @return LengthAwarePaginator<Invoice>
|
||||
* @return Builder<Invoice>
|
||||
*/
|
||||
public function handle(InvoiceFilterScope $filter): LengthAwarePaginator
|
||||
public function handle(InvoiceFilterScope $filter): Builder
|
||||
{
|
||||
return Invoice::withFilter($filter)->with('positions')->paginate(15);
|
||||
return $filter->getQuery()->query(fn ($q) => $q->with('positions'));
|
||||
}
|
||||
|
||||
public function asController(ActionRequest $request): Response
|
||||
|
@ -32,7 +32,7 @@ class InvoiceIndexAction
|
|||
$filter = InvoiceFilterScope::fromRequest($request->input('filter', ''));
|
||||
|
||||
return Inertia::render('invoice/Index', [
|
||||
'data' => InvoiceResource::collection($this->handle($filter)),
|
||||
'data' => InvoiceResource::collection($this->handle($filter)->paginate(15)),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace App\Invoice\Actions;
|
|||
|
||||
use App\Invoice\BillDocument;
|
||||
use App\Invoice\BillKind;
|
||||
use App\Invoice\Enums\InvoiceStatus;
|
||||
use App\Invoice\Mails\BillMail;
|
||||
use App\Invoice\Mails\RememberMail;
|
||||
use App\Invoice\Models\Invoice;
|
||||
|
|
|
@ -39,7 +39,7 @@ class MassStoreAction
|
|||
foreach ($memberGroup as $members) {
|
||||
$invoice = Invoice::createForMember($members->first(), $members, $year);
|
||||
$invoice->save();
|
||||
$invoice->positions()->createMany($invoice->positions);
|
||||
$invoice->positions()->createMany($invoice->positions->toArray());
|
||||
$invoices->push($invoice->fresh('positions'));
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ abstract class InvoiceDocument extends Document
|
|||
|
||||
public static function fromInvoice(Invoice $invoice): self
|
||||
{
|
||||
return static::withoutMagicalCreationFrom([
|
||||
return static::factory()->withoutMagicalCreation()->from([
|
||||
'toName' => $invoice->to['name'],
|
||||
'toAddress' => $invoice->to['address'],
|
||||
'toZip' => $invoice->to['zip'],
|
||||
|
|
|
@ -2,50 +2,73 @@
|
|||
|
||||
namespace App\Invoice;
|
||||
|
||||
use App\Setting\Contracts\Indexable;
|
||||
use App\Setting\Contracts\Storeable;
|
||||
use App\Setting\LocalSettings;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
|
||||
class InvoiceSettings extends LocalSettings implements Indexable, Storeable
|
||||
class InvoiceSettings extends LocalSettings implements Storeable
|
||||
{
|
||||
public string $from_long;
|
||||
|
||||
public string $from;
|
||||
|
||||
public string $mobile;
|
||||
|
||||
public string $email;
|
||||
|
||||
public string $website;
|
||||
|
||||
public string $address;
|
||||
|
||||
public string $place;
|
||||
|
||||
public string $zip;
|
||||
|
||||
public string $iban;
|
||||
|
||||
public string $bic;
|
||||
public ?string $from_long;
|
||||
public ?string $from;
|
||||
public ?string $mobile;
|
||||
public ?string $email;
|
||||
public ?string $website;
|
||||
public ?string $address;
|
||||
public ?string $place;
|
||||
public ?string $zip;
|
||||
public ?string $iban;
|
||||
public ?string $bic;
|
||||
public ?int $rememberWeeks;
|
||||
|
||||
public static function group(): string
|
||||
{
|
||||
return 'bill';
|
||||
}
|
||||
|
||||
public static function slug(): string
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function viewData(): array
|
||||
{
|
||||
return 'bill';
|
||||
return [
|
||||
'data' => [
|
||||
'from_long' => $this->from_long,
|
||||
'from' => $this->from,
|
||||
'mobile' => $this->mobile,
|
||||
'email' => $this->email,
|
||||
'website' => $this->website,
|
||||
'address' => $this->address,
|
||||
'place' => $this->place,
|
||||
'zip' => $this->zip,
|
||||
'iban' => $this->iban,
|
||||
'bic' => $this->bic,
|
||||
'rememberWeeks' => $this->rememberWeeks,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public static function indexAction(): string
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return SettingIndexAction::class;
|
||||
return [
|
||||
'from_long' => '',
|
||||
'from' => '',
|
||||
'mobile' => '',
|
||||
'email' => '',
|
||||
'website' => '',
|
||||
'address' => '',
|
||||
'place' => '',
|
||||
'zip' => '',
|
||||
'iban' => '',
|
||||
'bic' => '',
|
||||
'rememberWeeks' => '',
|
||||
];
|
||||
}
|
||||
|
||||
public static function storeAction(): string
|
||||
public function beforeSave(ActionRequest $request): void
|
||||
{
|
||||
return SettingSaveAction::class;
|
||||
}
|
||||
|
||||
public static function title(): string
|
||||
|
|
|
@ -6,20 +6,25 @@ use App\Invoice\BillDocument;
|
|||
use App\Invoice\BillKind;
|
||||
use App\Invoice\Enums\InvoiceStatus;
|
||||
use App\Invoice\InvoiceDocument;
|
||||
use App\Invoice\InvoiceSettings;
|
||||
use App\Invoice\RememberDocument;
|
||||
use App\Invoice\Scopes\InvoiceFilterScope;
|
||||
use App\Member\Member;
|
||||
use App\Payment\Subscription;
|
||||
use Database\Factories\Invoice\Models\InvoiceFactory;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Laravel\Scout\Searchable;
|
||||
use stdClass;
|
||||
|
||||
class Invoice extends Model
|
||||
{
|
||||
/** @use HasFactory<InvoiceFactory> */
|
||||
use HasFactory;
|
||||
use Searchable;
|
||||
|
||||
public $guarded = [];
|
||||
|
||||
|
@ -27,16 +32,12 @@ class Invoice extends Model
|
|||
'to' => 'json',
|
||||
'status' => InvoiceStatus::class,
|
||||
'via' => BillKind::class,
|
||||
];
|
||||
|
||||
/** @var array<int, string> */
|
||||
public $dates = [
|
||||
'sent_at',
|
||||
'last_remembered_at',
|
||||
'sent_at' => 'datetime',
|
||||
'last_remembered_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return HasMany<InvoicePosition>
|
||||
* @return HasMany<InvoicePosition, $this>
|
||||
*/
|
||||
public function positions(): HasMany
|
||||
{
|
||||
|
@ -48,7 +49,6 @@ class Invoice extends Model
|
|||
*/
|
||||
public static function createForMember(Member $member, Collection $members, int $year, Subscription $subscription = null): self
|
||||
{
|
||||
$subscription = $subscription ?: $member->subscription;
|
||||
$invoice = new self([
|
||||
'to' => [
|
||||
'name' => 'Familie ' . $member->lastname,
|
||||
|
@ -65,7 +65,8 @@ class Invoice extends Model
|
|||
|
||||
$positions = collect([]);
|
||||
foreach ($members as $member) {
|
||||
foreach ($subscription->children as $child) {
|
||||
$memberSubscription = $subscription ?: $member->subscription;
|
||||
foreach ($memberSubscription->children as $child) {
|
||||
$positions->push([
|
||||
'description' => str($child->name)->replace('{name}', $member->firstname . ' ' . $member->lastname)->replace('{year}', (string) $year),
|
||||
'price' => $child->amount,
|
||||
|
@ -111,22 +112,14 @@ class Invoice extends Model
|
|||
*
|
||||
* @return Builder<self>
|
||||
*/
|
||||
public function scopeWhereNeedsRemember(Builder $query): Builder
|
||||
public function scopeWhereNeedsRemember(Builder $query, ?int $weeks = null): Builder
|
||||
{
|
||||
$weeks = $weeks ?: app(InvoiceSettings::class)->rememberWeeks;
|
||||
return $query
|
||||
->where('status', InvoiceStatus::SENT)
|
||||
->whereNotNull('sent_at')
|
||||
->whereNotNull('last_remembered_at')
|
||||
->where('last_remembered_at', '<=', now()->subMonths(3));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder<self> $query
|
||||
* @return Builder<self>
|
||||
*/
|
||||
public function scopeWithFilter(Builder $query, InvoiceFilterScope $filter): Builder
|
||||
{
|
||||
return $filter->apply($query);
|
||||
->where('last_remembered_at', '<=', now()->subWeeks($weeks));
|
||||
}
|
||||
|
||||
public function getMailRecipient(): stdClass
|
||||
|
@ -154,4 +147,20 @@ class Invoice extends Model
|
|||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the indexable data array for the model.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toSearchableArray(): array
|
||||
{
|
||||
return [
|
||||
'to' => implode(', ', $this->to),
|
||||
'usage' => $this->usage,
|
||||
'greeting' => $this->greeting,
|
||||
'mail_email' => $this->mail_email,
|
||||
'status' => $this->status->value,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue