Compare commits
No commits in common. "master" and "1.9.31" have entirely different histories.
|
@ -1,14 +1,13 @@
|
||||||
FROM php:8.3.11-fpm AS php
|
FROM php:8.1.6-fpm as php
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN ls /app
|
RUN ls /app
|
||||||
RUN apt-get update
|
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 libzip-dev imagemagick libmagickwand-dev
|
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 --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 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 exif intl mbstring pcntl zip
|
RUN docker-php-ext-install pdo_mysql curl gd exif intl mbstring pcntl
|
||||||
RUN pecl install redis && docker-php-ext-enable redis
|
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-configure gd --with-jpeg
|
||||||
RUN docker-php-ext-install gd
|
RUN docker-php-ext-enable gd
|
||||||
RUN usermod -s /bin/bash www-data
|
RUN usermod -s /bin/bash www-data
|
||||||
RUN echo 'memory_limit = 2G' >> /usr/local/etc/php/conf.d/99-custom-php-memlimit.ini
|
RUN echo 'memory_limit = 2G' >> /usr/local/etc/php/conf.d/99-custom-php-memlimit.ini
|
||||||
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
#!/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.7.9 AS composer
|
FROM composer:2.2.7 as composer
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . /app
|
COPY . /app
|
||||||
RUN composer install --ignore-platform-reqs --no-dev
|
RUN composer install --ignore-platform-reqs --no-dev
|
||||||
RUN php artisan telescope:publish
|
RUN php artisan telescope:publish
|
||||||
RUN php artisan horizon:publish
|
RUN php artisan horizon:publish
|
||||||
|
|
||||||
FROM node:20.15.0-slim AS node
|
FROM node:18.13.0-slim as node
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . /app
|
COPY . /app
|
||||||
RUN npm install && npm run prod && npm run img && rm -R node_modules
|
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
|
WORKDIR /app
|
||||||
COPY --from=node /app /app
|
COPY --from=node /app /app
|
||||||
COPY --from=composer /app/public/vendor /app/public/vendor
|
COPY --from=composer /app/public/vendor /app/public/vendor
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
FROM composer:2.7.9 AS composer
|
FROM composer:2.2.7 as composer
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . /app
|
COPY . /app
|
||||||
RUN composer install --ignore-platform-reqs --no-dev
|
RUN composer install --ignore-platform-reqs --no-dev
|
||||||
|
|
||||||
FROM node:20.15.0-slim AS node
|
FROM node:17.9.0-slim as node
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . /app
|
COPY . /app
|
||||||
RUN npm install && npm run prod && npm run img && rm -R node_modules
|
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 . /app
|
||||||
COPY --chown=www-data:www-data --from=node /app/public /app/public
|
COPY --chown=www-data:www-data --from=node /app/public /app/public
|
||||||
COPY --chown=www-data:www-data --from=composer /app/vendor /app/vendor
|
COPY --chown=www-data:www-data --from=composer /app/vendor /app/vendor
|
||||||
|
@ -20,7 +20,7 @@ RUN php artisan horizon:publish
|
||||||
USER root
|
USER root
|
||||||
COPY ./.docker/php /bin
|
COPY ./.docker/php /bin
|
||||||
|
|
||||||
VOLUME ["/app/packages/laravel-nami/.cookies", "/app/storage/app", "/app/resources/views/tex/invoice"]
|
VOLUME ["/app/packages/laravel-nami/.cookies", "/app/storage/app"]
|
||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
|
|
||||||
|
|
|
@ -15,11 +15,6 @@ mkdir -p /app/storage/app/public || true
|
||||||
chown -R www-data:www-data /app/packages/laravel-nami/.cookies
|
chown -R www-data:www-data /app/packages/laravel-nami/.cookies
|
||||||
chown -R www-data:www-data /app/storage/app
|
chown -R www-data:www-data /app/storage/app
|
||||||
|
|
||||||
if [ $APP_KEY = "YOUR_APP_KEY" ]; then
|
|
||||||
echo "----------------------- Keinen APP KEY gefunden. Key wird generiert: $(su www-data -c 'php artisan key:generate --show') ----------------------- Füge diesen Key als APP_KEY ein ---------------------"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $1 == "horizon" ]; then
|
if [ $1 == "horizon" ]; then
|
||||||
wait_for_db
|
wait_for_db
|
||||||
su www-data -c 'php artisan horizon'
|
su www-data -c 'php artisan horizon'
|
||||||
|
@ -27,6 +22,10 @@ fi
|
||||||
|
|
||||||
if [ $1 == "app" ]; then
|
if [ $1 == "app" ]; then
|
||||||
# --------------------------- ensure appkey is set ----------------------------
|
# --------------------------- ensure appkey is set ----------------------------
|
||||||
|
if [ $APP_KEY = "YOUR_APP_KEY" ]; then
|
||||||
|
echo "----------------------- Keinen APP KEY gefunden. Key wird generiert: $(su www-data -c 'php artisan key:generate --show') ----------------------- Füge diesen Key als APP_KEY ein ---------------------"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
wait_for_db
|
wait_for_db
|
||||||
php -r '$connection = new PDO("mysql:host='$DB_HOST';dbname='$DB_DATABASE'", "'$DB_USERNAME'", "'$DB_PASSWORD'"); $connection->query("DESCRIBE migrations");' > /dev/null || php artisan migrate --seed --force
|
php -r '$connection = new PDO("mysql:host='$DB_HOST';dbname='$DB_DATABASE'", "'$DB_USERNAME'", "'$DB_PASSWORD'"); $connection->query("DESCRIBE migrations");' > /dev/null || php artisan migrate --seed --force
|
||||||
su www-data -c 'php artisan migrate --force'
|
su www-data -c 'php artisan migrate --force'
|
||||||
|
|
64
.drone.yml
64
.drone.yml
|
@ -12,7 +12,7 @@ steps:
|
||||||
- git submodule update --init --recursive
|
- git submodule update --init --recursive
|
||||||
|
|
||||||
- name: composer_dev
|
- name: composer_dev
|
||||||
image: composer:2.7.9
|
image: composer:2.2.7
|
||||||
commands:
|
commands:
|
||||||
- composer install --ignore-platform-reqs --dev
|
- composer install --ignore-platform-reqs --dev
|
||||||
|
|
||||||
|
@ -21,25 +21,14 @@ steps:
|
||||||
commands:
|
commands:
|
||||||
- while ! mysqladmin ping -h db -u db -pdb --silent; do sleep 1; done
|
- while ! mysqladmin ping -h db -u db -pdb --silent; do sleep 1; done
|
||||||
|
|
||||||
- name: ocdb_healthcheck
|
|
||||||
image: mysql:oracle
|
|
||||||
commands:
|
|
||||||
- while ! mysqladmin ping -h ownclouddb -u owncloud -powncloud --silent; do sleep 1; done
|
|
||||||
|
|
||||||
- name: oc_healthcheck
|
|
||||||
image: zoomyboy/adrema-base:latest
|
|
||||||
commands:
|
|
||||||
- while ! curl --silent 'http://owncloudserver:8080/ocs/v1.php/cloud/capabilities?format=json' -u admin:admin | grep '"status":"ok"'; do sleep 1; done
|
|
||||||
|
|
||||||
- name: node
|
- name: node
|
||||||
image: node:20.15.0-slim
|
image: node:18.13.0-slim
|
||||||
commands:
|
commands:
|
||||||
- npm ci && cd packages/adrema-form && npm ci && npm run build && rm -R node_modules && cd ../../ && npm run img && npm run prod && rm -R node_modules
|
- npm ci && cd packages/adrema-form && npm ci && npm run build && cd ../../ && npm run img && npm run prod && rm -R node_modules
|
||||||
|
|
||||||
- name: tests
|
- name: tests
|
||||||
image: zoomyboy/adrema-base:latest
|
image: zoomyboy/adrema-base:latest
|
||||||
commands:
|
commands:
|
||||||
- touch .env
|
|
||||||
- php artisan migrate
|
- php artisan migrate
|
||||||
- php artisan test
|
- php artisan test
|
||||||
- rm -f .env
|
- rm -f .env
|
||||||
|
@ -69,8 +58,6 @@ steps:
|
||||||
XELATEX_BIN: /usr/bin/xelatex
|
XELATEX_BIN: /usr/bin/xelatex
|
||||||
SCOUT_DRIVER: database
|
SCOUT_DRIVER: database
|
||||||
MEILI_MASTER_KEY: abc
|
MEILI_MASTER_KEY: abc
|
||||||
TEST_OWNCLOUD_DOMAIN: http://owncloudserver:8080
|
|
||||||
TEST_NEXTCLOUD_DOMAIN: http://nextcloudserver:80
|
|
||||||
|
|
||||||
- name: docker_app_push
|
- name: docker_app_push
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
|
@ -103,7 +90,7 @@ steps:
|
||||||
event: tag
|
event: tag
|
||||||
|
|
||||||
- name: deploy
|
- name: deploy
|
||||||
image: zoomyboy/adrema-base:latest
|
image: php:8.1.6
|
||||||
environment:
|
environment:
|
||||||
SSH_KEY:
|
SSH_KEY:
|
||||||
from_secret: deploy_private_key
|
from_secret: deploy_private_key
|
||||||
|
@ -136,7 +123,7 @@ steps:
|
||||||
event: push
|
event: push
|
||||||
|
|
||||||
- name: composer_no_dev
|
- name: composer_no_dev
|
||||||
image: composer:2.7.9
|
image: composer:2.2.7
|
||||||
commands:
|
commands:
|
||||||
- composer install --ignore-platform-reqs --no-dev
|
- composer install --ignore-platform-reqs --no-dev
|
||||||
|
|
||||||
|
@ -173,47 +160,6 @@ services:
|
||||||
image: getmeili/meilisearch:v1.6
|
image: getmeili/meilisearch:v1.6
|
||||||
commands:
|
commands:
|
||||||
- meilisearch --master-key="abc"
|
- meilisearch --master-key="abc"
|
||||||
- name: ownclouddb
|
|
||||||
image: mariadb:10.11
|
|
||||||
environment:
|
|
||||||
MYSQL_ROOT_PASSWORD: owncloud
|
|
||||||
MYSQL_USER: owncloud
|
|
||||||
MYSQL_PASSWORD: owncloud
|
|
||||||
MYSQL_DATABASE: owncloud
|
|
||||||
MARIADB_AUTO_UPGRADE: 1
|
|
||||||
- name: owncloudserver
|
|
||||||
image: owncloud/server:10.10.0
|
|
||||||
environment:
|
|
||||||
OWNCLOUD_DOMAIN: http://owncloudserver:8080
|
|
||||||
OWNCLOUD_TRUSTED_DOMAINS: owncloudserver
|
|
||||||
OWNCLOUD_DB_TYPE: mysql
|
|
||||||
OWNCLOUD_DB_NAME: owncloud
|
|
||||||
OWNCLOUD_DB_USERNAME: owncloud
|
|
||||||
OWNCLOUD_DB_PASSWORD: owncloud
|
|
||||||
OWNCLOUD_DB_HOST: ownclouddb
|
|
||||||
OWNCLOUD_ADMIN_USERNAME: admin
|
|
||||||
OWNCLOUD_ADMIN_PASSWORD: admin
|
|
||||||
OWNCLOUD_MYSQL_UTF8MB4: true
|
|
||||||
OWNCLOUD_REDIS_ENABLED: false
|
|
||||||
OWNCLOUD_REDIS_HOST: false
|
|
||||||
- name: nextclouddb
|
|
||||||
image: mariadb:10.11
|
|
||||||
environment:
|
|
||||||
MYSQL_ROOT_PASSWORD: nextcloud
|
|
||||||
MYSQL_USER: nextcloud
|
|
||||||
MYSQL_PASSWORD: nextcloud
|
|
||||||
MYSQL_DATABASE: nextcloud
|
|
||||||
MARIADB_AUTO_UPGRADE: 1
|
|
||||||
- name: nextcloudserver
|
|
||||||
image: nextcloud
|
|
||||||
environment:
|
|
||||||
MYSQL_PASSWORD: nextcloud
|
|
||||||
MYSQL_DATABASE: nextcloud
|
|
||||||
MYSQL_USER: nextcloud
|
|
||||||
MYSQL_HOST: nextclouddb
|
|
||||||
NEXTCLOUD_ADMIN_USER: admin
|
|
||||||
NEXTCLOUD_ADMIN_PASSWORD: admin
|
|
||||||
NEXTCLOUD_TRUSTED_DOMAINS: nextcloudserver
|
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
event:
|
event:
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -16,7 +16,6 @@ Homestead.json
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
/storage/temp/
|
/storage/temp/
|
||||||
/storage/debugbar/
|
/storage/debugbar/
|
||||||
/tests/Fileshare/oc_tmp/*
|
|
||||||
|
|
||||||
# User data files
|
# User data files
|
||||||
/data/
|
/data/
|
||||||
|
@ -40,4 +39,3 @@ Homestead.json
|
||||||
/public/sprite.svg
|
/public/sprite.svg
|
||||||
/.php-cs-fixer.cache
|
/.php-cs-fixer.cache
|
||||||
/groups.sql
|
/groups.sql
|
||||||
/.phpunit.cache
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
[submodule "packages/silvaletter"]
|
||||||
|
path = packages/silvaletter
|
||||||
|
url = https://git.zoomyboy.de/silva/silvaletter.git
|
||||||
[submodule "packages/laravel-nami"]
|
[submodule "packages/laravel-nami"]
|
||||||
path = packages/laravel-nami
|
path = packages/laravel-nami
|
||||||
url = https://git.zoomyboy.de/silva/laravel-nami-api
|
url = https://git.zoomyboy.de/silva/laravel-nami-api
|
||||||
|
@ -11,9 +14,3 @@
|
||||||
path = packages/medialibrary-helper
|
path = packages/medialibrary-helper
|
||||||
url = https://git.zoomyboy.de/zoomyboy/medialibrary-helper.git
|
url = https://git.zoomyboy.de/zoomyboy/medialibrary-helper.git
|
||||||
branch = version2
|
branch = version2
|
||||||
[submodule "packages/flysystem-webdav"]
|
|
||||||
path = packages/flysystem-webdav
|
|
||||||
url = https://github.com/zoomyboy/flysystem-webdav.git
|
|
||||||
[submodule "packages/table-document"]
|
|
||||||
path = packages/table-document
|
|
||||||
url = https://git.zoomyboy.de/zoomyboy/table-document.git
|
|
||||||
|
|
148
CHANGELOG.md
148
CHANGELOG.md
|
@ -1,148 +0,0 @@
|
||||||
# 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.10.10
|
|
||||||
|
|
||||||
- Eine Formular-Vorlage kann nun auch Mail-Inhalte enthalten, die für die Formulare übernommen werden
|
|
||||||
|
|
||||||
### 1.10.9
|
|
||||||
|
|
||||||
- Nextcloud als neuen Type bei Datei-Verbindungen angelegt
|
|
||||||
|
|
||||||
### 1.10.8
|
|
||||||
|
|
||||||
- Anmeldeformulare: Bearbeiten von Teilnehmer\*innen ist nun möglich
|
|
||||||
|
|
||||||
### 1.10.7
|
|
||||||
|
|
||||||
- Anmeldeformulare: Versenden von Präventions-Unterlagen können nun an eine Feld-Bedingung geknüpft werden innerhalb der Veranstaltung
|
|
||||||
|
|
||||||
### 1.10.6
|
|
||||||
|
|
||||||
- Kleinere Fehler behoben
|
|
||||||
|
|
||||||
### 1.10.5
|
|
||||||
|
|
||||||
- Kleinere Fehler behoben
|
|
||||||
|
|
||||||
### 1.10.4
|
|
||||||
|
|
||||||
- Anmeldeformular: Erinnerung an Präventions-Unterlagen bei Teilnehmer\*innnen
|
|
||||||
|
|
||||||
### 1.10.3
|
|
||||||
|
|
||||||
- Anmeldeformulare: Ist NaMi-Feld "E-Mail" ausgewählt bei Formular-Feldern, muss die E-Mail-Adresse nun nicht mehr auf das Mitglied matchen. Dies ist nur noch bei Formular-Feldern mit NaMi-Feldern "Vorname", "Nachname" und "Geburtsdatum" der Fall.
|
|
|
@ -1,4 +1,4 @@
|
||||||
@servers(['docker' => ['stamm-silva@zoomyboy.de', 'stammgallier@stamm-gallier.de', 'dpsg-lennep@zoomyboy.de', 'dpsgbergischland@zoomyboy.de', 'dpsg-koeln@dpsg-koeln.de']])
|
@servers(['docker' => ['stammsilva@zoomyboy.de', 'stammgallier@stamm-gallier.de', 'dpsg-lennep@zoomyboy.de', 'dpsgbergischland@zoomyboy.de', 'dpsg-koeln@dpsg-koeln.de']])
|
||||||
|
|
||||||
@task('deploy', ['on' => 'docker'])
|
@task('deploy', ['on' => 'docker'])
|
||||||
cd $ADREMA_PATH
|
cd $ADREMA_PATH
|
||||||
|
|
31
README.md
31
README.md
|
@ -32,16 +32,16 @@ Außerdem ist AdReMa auch problemlos auf Handys und Tablets bedienbar ("mobiles
|
||||||
|
|
||||||
## Installation des Produktivsystems
|
## Installation des Produktivsystems
|
||||||
|
|
||||||
1. Verschieben der Docker-Compose
|
1. Herunterladen der Beispiel Docker-Compose
|
||||||
|
|
||||||
```cmd
|
```cmd
|
||||||
mv docker-compose.prod.yml docker-compose.yml
|
curl https://git.zoomyboy.de/silva/adrema/raw/branch/master/docker-compose.prod.yml -o docker-compose.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Anwenden der Beispiel Environmentvariablen-Datei
|
2. Herunterladen der Beispiel Environmentvariablen-Datei
|
||||||
|
|
||||||
```cmd
|
```cmd
|
||||||
mv .app.env.example .app.env
|
curl https://git.zoomyboy.de/silva/adrema/raw/branch/master/.app.env.example -o .app.env
|
||||||
```
|
```
|
||||||
|
|
||||||
3. In der `.app.env` notwendige Einstellungen vornehmen:
|
3. In der `.app.env` notwendige Einstellungen vornehmen:
|
||||||
|
@ -50,8 +50,7 @@ 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-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_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`)
|
- `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 neu erstellten, sicheren Passwort für die Datenbank versehen
|
- `DB_PASSWORD` und `MYSQL_PASSWORD`: Mit dem selben 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
|
- `USER_EMAIL` und `USER_PASSWORD`: Einstellen des standard Adrema Logins
|
||||||
|
|
||||||
4. Container zur Gennerierung des App-Key starten
|
4. Container zur Gennerierung des App-Key starten
|
||||||
|
@ -86,12 +85,6 @@ Außerdem ist AdReMa auch problemlos auf Handys und Tablets bedienbar ("mobiles
|
||||||
|
|
||||||
7. Nach kurzer Zeit ist AdReMa über <http://localhost:8000> erreichbar und es kann sich mit dem zuvor festgelegten Login eingeloggt werden
|
7. Nach kurzer Zeit ist AdReMa über <http://localhost:8000> erreichbar und es kann sich mit dem zuvor festgelegten Login eingeloggt werden
|
||||||
|
|
||||||
### Individuelle anpassungen
|
|
||||||
|
|
||||||
#### Rechnungswesen
|
|
||||||
|
|
||||||
Bei dem Setup wird im Daten-Verzeichniss ein Ordner `./data/setup` angelegt. Hier kann das Logo des Stammes in den Briefkopf eingefügt werden. Zusätzlich kann der Text der Rechnung und der Zahlungserinnerung angepasst werden, dafür ist ein grundlegendes Verständnis für `.tex` Datein erforderlich.
|
|
||||||
|
|
||||||
## Nutzen des Entwicklungssystmes
|
## Nutzen des Entwicklungssystmes
|
||||||
|
|
||||||
1. Klonen des Reposetories
|
1. Klonen des Reposetories
|
||||||
|
@ -100,22 +93,28 @@ Bei dem Setup wird im Daten-Verzeichniss ein Ordner `./data/setup` angelegt. Hie
|
||||||
git clone https://git.zoomyboy.de/silva/adrema.git
|
git clone https://git.zoomyboy.de/silva/adrema.git
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Kopieren der Beispiel Environmentvariablen-Datei
|
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
|
||||||
|
|
||||||
```cmd
|
```cmd
|
||||||
cp .app.env.example .app.env
|
cp .app.env.example .app.env
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Submodule aktuallisieren
|
4. Submodule aktuallisieren
|
||||||
|
|
||||||
```cmd
|
```cmd
|
||||||
git submodule update --init
|
git submodule update --init
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Container erstellen
|
5. Container erstellen
|
||||||
|
|
||||||
```cmd
|
```cmd
|
||||||
docker compose build
|
docker compose build
|
||||||
```
|
```
|
||||||
|
|
||||||
5. Mit Schritt 3 und den folgenden der [Installation des Produktivsystems](#installation-des-produktivsystems) fortfahren
|
6. Mit Schritt 3 und den folgenden der [Installation des Produktivsystems](#installation-des-produktivsystems) fortfahren
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Actions;
|
|
||||||
|
|
||||||
use DB;
|
|
||||||
use Illuminate\Support\Facades\Artisan;
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use Laravel\Telescope\Console\PruneCommand;
|
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
|
||||||
|
|
||||||
class DbMaintainAction
|
|
||||||
{
|
|
||||||
use AsAction;
|
|
||||||
|
|
||||||
public string $commandSignature = 'db:maintain';
|
|
||||||
|
|
||||||
public function handle(): void
|
|
||||||
{
|
|
||||||
Artisan::call(PruneCommand::class, ['--hours' => 168]); // 168h = 7 Tage
|
|
||||||
DB::select('optimize table telescope_entries');
|
|
||||||
Http::post('https://zoomyboy.de/maintain', ['url' => url()->current()]);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -22,7 +22,7 @@ class InsertMemberAction
|
||||||
{
|
{
|
||||||
$region = Region::firstWhere('nami_id', $member->regionId ?: -1);
|
$region = Region::firstWhere('nami_id', $member->regionId ?: -1);
|
||||||
|
|
||||||
$payload = [
|
return Member::updateOrCreate(['nami_id' => $member->id], [
|
||||||
'firstname' => $member->firstname,
|
'firstname' => $member->firstname,
|
||||||
'lastname' => $member->lastname,
|
'lastname' => $member->lastname,
|
||||||
'joined_at' => $member->joinedAt,
|
'joined_at' => $member->joinedAt,
|
||||||
|
@ -50,27 +50,7 @@ class InsertMemberAction
|
||||||
'nationality_id' => Nationality::where('nami_id', $member->nationalityId)->firstOrFail()->id,
|
'nationality_id' => Nationality::where('nami_id', $member->nationalityId)->firstOrFail()->id,
|
||||||
'mitgliedsnr' => $member->memberId,
|
'mitgliedsnr' => $member->memberId,
|
||||||
'version' => $member->version,
|
'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
|
public function getSubscription(NamiMember $member): ?Subscription
|
||||||
|
|
|
@ -4,14 +4,12 @@ namespace App;
|
||||||
|
|
||||||
use App\Nami\HasNamiField;
|
use App\Nami\HasNamiField;
|
||||||
use Cviebrock\EloquentSluggable\Sluggable;
|
use Cviebrock\EloquentSluggable\Sluggable;
|
||||||
use Database\Factories\ActivityFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
|
|
||||||
class Activity extends Model
|
class Activity extends Model
|
||||||
{
|
{
|
||||||
/** @use HasFactory<ActivityFactory> */
|
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
use HasNamiField;
|
use HasNamiField;
|
||||||
use Sluggable;
|
use Sluggable;
|
||||||
|
@ -34,7 +32,7 @@ class Activity extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return BelongsToMany<Subactivity, $this>
|
* @return BelongsToMany<Subactivity>
|
||||||
*/
|
*/
|
||||||
public function subactivities(): BelongsToMany
|
public function subactivities(): BelongsToMany
|
||||||
{
|
{
|
||||||
|
|
|
@ -54,7 +54,6 @@ class ActivityResource extends JsonResource
|
||||||
'index' => route('activity.index'),
|
'index' => route('activity.index'),
|
||||||
'create' => route('activity.create'),
|
'create' => route('activity.create'),
|
||||||
'membership_masslist' => route('membership.masslist.index'),
|
'membership_masslist' => route('membership.masslist.index'),
|
||||||
'membership_index' => route('membership.index'),
|
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,11 @@
|
||||||
|
|
||||||
namespace App;
|
namespace App;
|
||||||
|
|
||||||
use Database\Factories\ConfessionFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class Confession extends Model
|
class Confession extends Model
|
||||||
{
|
{
|
||||||
/** @use HasFactory<ConfessionFactory> */
|
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
public $fillable = ['name', 'nami_id', 'is_null'];
|
public $fillable = ['name', 'nami_id', 'is_null'];
|
||||||
|
|
|
@ -2,13 +2,11 @@
|
||||||
|
|
||||||
namespace App\Console;
|
namespace App\Console;
|
||||||
|
|
||||||
use App\Actions\DbMaintainAction;
|
|
||||||
use App\Form\Actions\PreventionRememberAction;
|
|
||||||
use App\Initialize\InitializeMembers;
|
use App\Initialize\InitializeMembers;
|
||||||
use App\Invoice\Actions\InvoiceSendAction;
|
use App\Invoice\Actions\InvoiceSendAction;
|
||||||
use App\Prevention\Actions\YearlyRememberAction;
|
|
||||||
use Illuminate\Console\Scheduling\Schedule;
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||||
|
use Laravel\Telescope\Console\PruneCommand;
|
||||||
|
|
||||||
class Kernel extends ConsoleKernel
|
class Kernel extends ConsoleKernel
|
||||||
{
|
{
|
||||||
|
@ -20,9 +18,6 @@ class Kernel extends ConsoleKernel
|
||||||
protected $commands = [
|
protected $commands = [
|
||||||
InvoiceSendAction::class,
|
InvoiceSendAction::class,
|
||||||
InitializeMembers::class,
|
InitializeMembers::class,
|
||||||
DbMaintainAction::class,
|
|
||||||
PreventionRememberAction::class,
|
|
||||||
YearlyRememberAction::class,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,11 +27,8 @@ class Kernel extends ConsoleKernel
|
||||||
*/
|
*/
|
||||||
protected function schedule(Schedule $schedule)
|
protected function schedule(Schedule $schedule)
|
||||||
{
|
{
|
||||||
$schedule->command(DbMaintainAction::class)->daily();
|
$schedule->command(PruneCommand::class, ['--hours' => 168])->daily(); // 168h = 7 Tage
|
||||||
$schedule->command(InitializeMembers::class)->dailyAt('03:00');
|
$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;
|
namespace App\Contribution\Actions;
|
||||||
|
|
||||||
use App\Contribution\Contracts\HasContributionData;
|
|
||||||
use App\Contribution\ContributionFactory;
|
use App\Contribution\ContributionFactory;
|
||||||
use App\Contribution\Requests\GenerateRequest;
|
use App\Contribution\Documents\ContributionDocument;
|
||||||
use App\Rules\JsonBase64Rule;
|
use App\Rules\JsonBase64Rule;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Lorisleiva\Actions\ActionRequest;
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
use Zoomyboy\Tex\BaseCompiler;
|
use Zoomyboy\Tex\BaseCompiler;
|
||||||
use Zoomyboy\Tex\Tex;
|
use Zoomyboy\Tex\Tex;
|
||||||
|
@ -15,19 +15,23 @@ class GenerateAction
|
||||||
{
|
{
|
||||||
use AsAction;
|
use AsAction;
|
||||||
|
|
||||||
public function handle(HasContributionData $request): BaseCompiler
|
/**
|
||||||
|
* @param class-string<ContributionDocument> $document
|
||||||
|
* @param array<string, mixed> $payload
|
||||||
|
*/
|
||||||
|
public function handle(string $document, array $payload): BaseCompiler
|
||||||
{
|
{
|
||||||
return Tex::compile($request->type()::fromPayload($request));
|
return Tex::compile($document::fromRequest($payload));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function asController(GenerateRequest $request): BaseCompiler|JsonResponse
|
public function asController(ActionRequest $request): BaseCompiler
|
||||||
{
|
{
|
||||||
app(ContributionFactory::class)->validateType($request);
|
$payload = $this->payload($request);
|
||||||
$request->validateContribution();
|
$type = data_get($payload, 'type');
|
||||||
|
ValidateAction::validateType($type);
|
||||||
|
Validator::make($payload, app(ContributionFactory::class)->rules($type))->validate();
|
||||||
|
|
||||||
return $request->input('validate')
|
return $this->handle($type, $payload);
|
||||||
? response()->json([])
|
|
||||||
: $this->handle($request);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,4 +43,12 @@ class GenerateAction
|
||||||
'payload' => [new JsonBase64Rule()],
|
'payload' => [new JsonBase64Rule()],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
private function payload(ActionRequest $request): array
|
||||||
|
{
|
||||||
|
return json_decode(rawurldecode(base64_decode($request->input('payload', ''))), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,8 @@
|
||||||
|
|
||||||
namespace App\Contribution\Actions;
|
namespace App\Contribution\Actions;
|
||||||
|
|
||||||
use App\Contribution\Contracts\HasContributionData;
|
use App\Contribution\Documents\ContributionDocument;
|
||||||
use App\Contribution\ContributionFactory;
|
use Lorisleiva\Actions\ActionRequest;
|
||||||
use App\Contribution\Requests\GenerateApiRequest;
|
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
use Zoomyboy\Tex\BaseCompiler;
|
use Zoomyboy\Tex\BaseCompiler;
|
||||||
use Zoomyboy\Tex\Tex;
|
use Zoomyboy\Tex\Tex;
|
||||||
|
@ -14,17 +13,26 @@ class GenerateApiAction
|
||||||
use AsAction;
|
use AsAction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo merge this with GenerateAction
|
* @param class-string<ContributionDocument> $document
|
||||||
|
* @param array<string, mixed> $payload
|
||||||
*/
|
*/
|
||||||
public function handle(HasContributionData $request): BaseCompiler
|
public function handle(string $document, array $payload): BaseCompiler
|
||||||
{
|
{
|
||||||
return Tex::compile($request->type()::fromPayload($request));
|
return Tex::compile($document::fromApiRequest($payload));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function asController(GenerateApiRequest $request): BaseCompiler
|
public function asController(ActionRequest $request): BaseCompiler
|
||||||
{
|
{
|
||||||
app(ContributionFactory::class)->validateType($request);
|
ValidateAction::validateType($request->input('type'));
|
||||||
|
|
||||||
return $this->handle($request);
|
return $this->handle($request->input('type'), $request->input());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,30 +0,0 @@
|
||||||
<?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,16 +2,13 @@
|
||||||
|
|
||||||
namespace App\Contribution;
|
namespace App\Contribution;
|
||||||
|
|
||||||
use App\Contribution\Contracts\HasContributionData;
|
|
||||||
use App\Contribution\Documents\BdkjHesse;
|
use App\Contribution\Documents\BdkjHesse;
|
||||||
use App\Contribution\Documents\ContributionDocument;
|
use App\Contribution\Documents\ContributionDocument;
|
||||||
use App\Contribution\Documents\RdpNrwDocument;
|
use App\Contribution\Documents\RdpNrwDocument;
|
||||||
use App\Contribution\Documents\CityRemscheidDocument;
|
use App\Contribution\Documents\CityRemscheidDocument;
|
||||||
use App\Contribution\Documents\CitySolingenDocument;
|
use App\Contribution\Documents\CitySolingenDocument;
|
||||||
use App\Contribution\Documents\CityFrankfurtMainDocument;
|
use App\Contribution\Documents\CityFrankfurtMainDocument;
|
||||||
use App\Contribution\Documents\WuppertalDocument;
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Validator;
|
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class ContributionFactory
|
class ContributionFactory
|
||||||
|
@ -25,17 +22,16 @@ class ContributionFactory
|
||||||
CityRemscheidDocument::class,
|
CityRemscheidDocument::class,
|
||||||
CityFrankfurtMainDocument::class,
|
CityFrankfurtMainDocument::class,
|
||||||
BdkjHesse::class,
|
BdkjHesse::class,
|
||||||
WuppertalDocument::class,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection<int, array{name: string, id: class-string<ContributionDocument>}>
|
* @return Collection<int, array{title: mixed, class: mixed}>
|
||||||
*/
|
*/
|
||||||
public function compilerSelect(): Collection
|
public function compilerSelect(): Collection
|
||||||
{
|
{
|
||||||
return collect($this->documents)->map(fn ($document) => [
|
return collect($this->documents)->map(fn ($document) => [
|
||||||
'name' => $document::getName(),
|
'title' => $document::getName(),
|
||||||
'id' => $document,
|
'class' => $document,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,9 +57,4 @@ class ContributionFactory
|
||||||
...$type::rules(),
|
...$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
|
public static function fromModels(array $ids): Collection
|
||||||
{
|
{
|
||||||
return Member::whereIn('id', $ids)->orderByRaw('lastname, firstname')->get()->map(fn ($member) => self::factory()->withoutMagicalCreation()->from([
|
return Member::whereIn('id', $ids)->orderByRaw('lastname, firstname')->get()->map(fn ($member) => self::withoutMagicalCreationFrom([
|
||||||
...$member->toArray(),
|
...$member->toArray(),
|
||||||
'birthday' => $member->birthday->toAtomString(),
|
'birthday' => $member->birthday->toAtomString(),
|
||||||
'isLeader' => $member->isLeader(),
|
'isLeader' => $member->isLeader(),
|
||||||
|
@ -44,51 +44,41 @@ class MemberData extends Data
|
||||||
*/
|
*/
|
||||||
public static function fromApi(array $data): Collection
|
public static function fromApi(array $data): Collection
|
||||||
{
|
{
|
||||||
return collect($data)->map(fn ($member) => self::factory()->withoutMagicalCreation()->from([
|
return collect($data)->map(fn ($member) => self::withoutMagicalCreationFrom([
|
||||||
...$member,
|
...$member,
|
||||||
'birthday' => Carbon::parse($member['birthday'])->toAtomString(),
|
'birthday' => Carbon::parse($member['birthday'])->toAtomString(),
|
||||||
'gender' => $member['gender'] ? Gender::fromString($member['gender']) : null,
|
'gender' => Gender::fromString($member['gender']),
|
||||||
'isLeader' => $member['is_leader'],
|
'isLeader' => $member['is_leader'],
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fullname(): string
|
public function fullname(): string
|
||||||
{
|
{
|
||||||
return $this->firstname . ' ' . $this->lastname;
|
return $this->firstname.' '.$this->lastname;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function separatedName(): string
|
public function separatedName(): string
|
||||||
{
|
{
|
||||||
return $this->lastname . ', ' . $this->firstname;
|
return $this->lastname.', '.$this->firstname;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fullAddress(): string
|
public function fullAddress(): string
|
||||||
{
|
{
|
||||||
return $this->address . ', ' . $this->zip . ' ' . $this->location;
|
return $this->address.', '.$this->zip.' '.$this->location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function city(): string
|
public function city(): string
|
||||||
{
|
{
|
||||||
return $this->zip . ' ' . $this->location;
|
return $this->zip.' '.$this->location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function age(): int
|
public function age(): string
|
||||||
{
|
{
|
||||||
return intval($this->birthday->diffInYears(now()));
|
return (string) $this->birthday->diffInYears(now()) ?: '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function birthYear(): string
|
public function birthYear(): string
|
||||||
{
|
{
|
||||||
return (string) $this->birthday->year;
|
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,25 +2,22 @@
|
||||||
|
|
||||||
namespace App\Contribution\Documents;
|
namespace App\Contribution\Documents;
|
||||||
|
|
||||||
use App\Contribution\Contracts\HasContributionData;
|
|
||||||
use App\Contribution\Data\MemberData;
|
use App\Contribution\Data\MemberData;
|
||||||
use App\Contribution\Traits\HasPdfBackground;
|
|
||||||
use App\Country;
|
use App\Country;
|
||||||
use App\Form\Enums\SpecialType;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Zoomyboy\Tex\Engine;
|
||||||
|
use Zoomyboy\Tex\Template;
|
||||||
|
|
||||||
class BdkjHesse extends ContributionDocument
|
class BdkjHesse extends ContributionDocument
|
||||||
{
|
{
|
||||||
|
|
||||||
use HasPdfBackground;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Collection<int, Collection<int, MemberData>> $members
|
* @param Collection<int, Collection<int, MemberData>> $members
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public Carbon $dateFrom,
|
public string $dateFrom,
|
||||||
public Carbon $dateUntil,
|
public string $dateUntil,
|
||||||
public string $zipLocation,
|
public string $zipLocation,
|
||||||
public ?Country $country,
|
public ?Country $country,
|
||||||
public Collection $members,
|
public Collection $members,
|
||||||
|
@ -28,7 +25,6 @@ class BdkjHesse extends ContributionDocument
|
||||||
public ?string $filename = '',
|
public ?string $filename = '',
|
||||||
public string $type = 'F',
|
public string $type = 'F',
|
||||||
) {
|
) {
|
||||||
$this->setEventName($eventName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dateFrom(): string
|
public function dateFrom(): string
|
||||||
|
@ -41,15 +37,33 @@ class BdkjHesse extends ContributionDocument
|
||||||
return Carbon::parse($this->dateUntil)->format('d.m.Y');
|
return Carbon::parse($this->dateUntil)->format('d.m.Y');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function fromPayload(HasContributionData $request): self
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static function fromRequest(array $request): self
|
||||||
{
|
{
|
||||||
return new self(
|
return new self(
|
||||||
dateFrom: $request->dateFrom(),
|
dateFrom: $request['dateFrom'],
|
||||||
dateUntil: $request->dateUntil(),
|
dateUntil: $request['dateUntil'],
|
||||||
zipLocation: $request->zipLocation(),
|
zipLocation: $request['zipLocation'],
|
||||||
country: $request->country(),
|
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||||
members: $request->members()->chunk(20),
|
members: MemberData::fromModels($request['members'])->chunk(20),
|
||||||
eventName: $request->eventName(),
|
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'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +74,7 @@ class BdkjHesse extends ContributionDocument
|
||||||
|
|
||||||
public function durationDays(): int
|
public function durationDays(): int
|
||||||
{
|
{
|
||||||
return intVal(Carbon::parse($this->dateUntil)->diffInDays(Carbon::parse($this->dateFrom))) + 1;
|
return Carbon::parse($this->dateUntil)->diffInDays(Carbon::parse($this->dateFrom)) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -100,9 +114,36 @@ class BdkjHesse extends ContributionDocument
|
||||||
return $member->birthYear();
|
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
|
public static function getName(): string
|
||||||
{
|
{
|
||||||
return 'BDKJ Hessen';
|
return 'Für BDKJ Hessen erstellen';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,17 +156,7 @@ class BdkjHesse extends ContributionDocument
|
||||||
'dateUntil' => 'required|string|date_format:Y-m-d',
|
'dateUntil' => 'required|string|date_format:Y-m-d',
|
||||||
'country' => 'required|integer|exists:countries,id',
|
'country' => 'required|integer|exists:countries,id',
|
||||||
'zipLocation' => 'required|string',
|
'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,29 +2,25 @@
|
||||||
|
|
||||||
namespace App\Contribution\Documents;
|
namespace App\Contribution\Documents;
|
||||||
|
|
||||||
use App\Contribution\Contracts\HasContributionData;
|
|
||||||
use App\Contribution\Data\MemberData;
|
use App\Contribution\Data\MemberData;
|
||||||
use App\Contribution\Traits\FormatsDates;
|
|
||||||
use App\Contribution\Traits\HasPdfBackground;
|
|
||||||
use App\Country;
|
use App\Country;
|
||||||
use App\Form\Enums\SpecialType;
|
|
||||||
use App\Invoice\InvoiceSettings;
|
use App\Invoice\InvoiceSettings;
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Zoomyboy\Tex\Engine;
|
||||||
|
use Zoomyboy\Tex\Template;
|
||||||
|
|
||||||
class CityFrankfurtMainDocument extends ContributionDocument
|
class CityFrankfurtMainDocument extends ContributionDocument
|
||||||
{
|
{
|
||||||
use HasPdfBackground;
|
|
||||||
use FormatsDates;
|
|
||||||
|
|
||||||
public string $fromName;
|
public string $fromName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Collection<int, Collection<int, MemberData>> $members
|
* @param Collection<int, Collection<int, MemberData>> $members
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public Carbon $dateFrom,
|
public string $dateFrom,
|
||||||
public Carbon $dateUntil,
|
public string $dateUntil,
|
||||||
public string $zipLocation,
|
public string $zipLocation,
|
||||||
public ?Country $country,
|
public ?Country $country,
|
||||||
public Collection $members,
|
public Collection $members,
|
||||||
|
@ -32,22 +28,50 @@ class CityFrankfurtMainDocument extends ContributionDocument
|
||||||
public ?string $filename = '',
|
public ?string $filename = '',
|
||||||
public string $type = 'F',
|
public string $type = 'F',
|
||||||
) {
|
) {
|
||||||
$this->setEventName($eventName);
|
|
||||||
$this->fromName = app(InvoiceSettings::class)->from_long;
|
$this->fromName = app(InvoiceSettings::class)->from_long;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function fromPayload(HasContributionData $request): self
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static function fromRequest(array $request): self
|
||||||
{
|
{
|
||||||
return new self(
|
return new self(
|
||||||
dateFrom: $request->dateFrom(),
|
dateFrom: $request['dateFrom'],
|
||||||
dateUntil: $request->dateUntil(),
|
dateUntil: $request['dateUntil'],
|
||||||
zipLocation: $request->zipLocation(),
|
zipLocation: $request['zipLocation'],
|
||||||
country: $request->country(),
|
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||||
members: $request->members()->chunk(15),
|
members: MemberData::fromModels($request['members'])->chunk(15),
|
||||||
eventName: $request->eventName(),
|
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
|
public function countryName(): string
|
||||||
{
|
{
|
||||||
return $this->country->name;
|
return $this->country->name;
|
||||||
|
@ -58,9 +82,56 @@ class CityFrankfurtMainDocument extends ContributionDocument
|
||||||
return count($this->members);
|
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
|
public static function getName(): string
|
||||||
{
|
{
|
||||||
return 'Frankfurt';
|
return 'Für Frankfurt erstellen';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,17 +144,7 @@ class CityFrankfurtMainDocument extends ContributionDocument
|
||||||
'dateUntil' => 'required|string|date_format:Y-m-d',
|
'dateUntil' => 'required|string|date_format:Y-m-d',
|
||||||
'country' => 'required|integer|exists:countries,id',
|
'country' => 'required|integer|exists:countries,id',
|
||||||
'zipLocation' => 'required|string',
|
'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,56 +2,107 @@
|
||||||
|
|
||||||
namespace App\Contribution\Documents;
|
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\Country;
|
||||||
use App\Form\Enums\SpecialType;
|
|
||||||
use App\Member\Member;
|
use App\Member\Member;
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Zoomyboy\Tex\Engine;
|
||||||
|
use Zoomyboy\Tex\Template;
|
||||||
|
|
||||||
class CityRemscheidDocument extends ContributionDocument
|
class CityRemscheidDocument extends ContributionDocument
|
||||||
{
|
{
|
||||||
use HasPdfBackground;
|
|
||||||
use FormatsDates;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Collection<int, Collection<int, Member>> $leaders
|
* @param Collection<int, Collection<int, Member>> $leaders
|
||||||
* @param Collection<int, Collection<int, Member>> $children
|
* @param Collection<int, Collection<int, Member>> $children
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public Carbon $dateFrom,
|
public string $dateFrom,
|
||||||
public Carbon $dateUntil,
|
public string $dateUntil,
|
||||||
public string $zipLocation,
|
public string $zipLocation,
|
||||||
public ?Country $country,
|
public ?Country $country,
|
||||||
public Collection $leaders,
|
public Collection $leaders,
|
||||||
public Collection $children,
|
public Collection $children,
|
||||||
public ?string $filename = '',
|
public ?string $filename = '',
|
||||||
public string $type = 'F',
|
public string $type = 'F',
|
||||||
public string $eventName = '',
|
|
||||||
) {
|
) {
|
||||||
$this->setEventName($eventName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function fromPayload(HasContributionData $request): self
|
public function niceDateFrom(): string
|
||||||
{
|
{
|
||||||
[$leaders, $children] = $request->members()->partition(fn ($member) => $member->isLeader);
|
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);
|
||||||
|
|
||||||
return new self(
|
return new self(
|
||||||
dateFrom: $request->dateFrom(),
|
dateFrom: $request['dateFrom'],
|
||||||
dateUntil: $request->dateUntil(),
|
dateUntil: $request['dateUntil'],
|
||||||
zipLocation: $request->zipLocation(),
|
zipLocation: $request['zipLocation'],
|
||||||
country: $request->country(),
|
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||||
leaders: $leaders->values()->toBase()->chunk(6),
|
leaders: $leaders->values()->toBase()->chunk(6),
|
||||||
children: $children->values()->toBase()->chunk(20),
|
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
|
public static function getName(): string
|
||||||
{
|
{
|
||||||
return 'Remscheid';
|
return 'Für Remscheid erstellen';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,15 +117,4 @@ class CityRemscheidDocument extends ContributionDocument
|
||||||
'country' => 'required|integer|exists:countries,id',
|
'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;
|
namespace App\Contribution\Documents;
|
||||||
|
|
||||||
use App\Contribution\Contracts\HasContributionData;
|
|
||||||
use App\Contribution\Data\MemberData;
|
use App\Contribution\Data\MemberData;
|
||||||
use App\Form\Enums\SpecialType;
|
|
||||||
use App\Invoice\InvoiceSettings;
|
use App\Invoice\InvoiceSettings;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Zoomyboy\Tex\Engine;
|
use Zoomyboy\Tex\Engine;
|
||||||
|
use Zoomyboy\Tex\Template;
|
||||||
|
|
||||||
class CitySolingenDocument extends ContributionDocument
|
class CitySolingenDocument extends ContributionDocument
|
||||||
{
|
{
|
||||||
|
@ -18,28 +18,41 @@ class CitySolingenDocument extends ContributionDocument
|
||||||
* @param Collection<int, MemberData> $members
|
* @param Collection<int, MemberData> $members
|
||||||
*/
|
*/
|
||||||
final private function __construct(
|
final private function __construct(
|
||||||
public Carbon $dateFrom,
|
public string $dateFrom,
|
||||||
public Carbon $dateUntil,
|
public string $dateUntil,
|
||||||
public string $zipLocation,
|
public string $zipLocation,
|
||||||
public Collection $members,
|
public Collection $members,
|
||||||
public string $eventName,
|
public string $eventName,
|
||||||
public string $type = 'F',
|
public string $type = 'F',
|
||||||
) {
|
) {
|
||||||
$this->setEventName($eventName);
|
|
||||||
$this->fromName = app(InvoiceSettings::class)->from_long;
|
$this->fromName = app(InvoiceSettings::class)->from_long;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static function fromPayload(HasContributionData $request): static
|
public static function fromRequest(array $request): static
|
||||||
{
|
{
|
||||||
return new static(
|
return new static(
|
||||||
dateFrom: $request->dateFrom(),
|
dateFrom: $request['dateFrom'],
|
||||||
dateUntil: $request->dateUntil(),
|
dateUntil: $request['dateUntil'],
|
||||||
zipLocation: $request->zipLocation(),
|
zipLocation: $request['zipLocation'],
|
||||||
members: $request->members(),
|
members: MemberData::fromModels($request['members']),
|
||||||
eventName: $request->eventName(),
|
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'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,8 +74,15 @@ class CitySolingenDocument extends ContributionDocument
|
||||||
return Carbon::parse($this->dateUntil)->format('d.m.Y');
|
return Carbon::parse($this->dateUntil)->format('d.m.Y');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function template(): Template
|
||||||
|
{
|
||||||
|
return Template::make('tex.templates.contribution');
|
||||||
|
}
|
||||||
|
|
||||||
public function checkboxes(): string
|
public function checkboxes(): string
|
||||||
{
|
{
|
||||||
|
$output = '';
|
||||||
|
|
||||||
$firstRow = collect(['B' => 'Jugendbildungsmaßnahme', 'G' => 'Gruppenleiter/innenschulung', 'FK' => 'Ferienkolonie', 'F' => 'Freizeitnaßnahme'])->map(function ($item, $key) {
|
$firstRow = collect(['B' => 'Jugendbildungsmaßnahme', 'G' => 'Gruppenleiter/innenschulung', 'FK' => 'Ferienkolonie', 'F' => 'Freizeitnaßnahme'])->map(function ($item, $key) {
|
||||||
return ($this->type === $key ? '\\checkedcheckbox' : '\\checkbox') . '{' . $item . '}';
|
return ($this->type === $key ? '\\checkedcheckbox' : '\\checkbox') . '{' . $item . '}';
|
||||||
})->implode(' & ') . ' \\\\';
|
})->implode(' & ') . ' \\\\';
|
||||||
|
@ -74,6 +94,16 @@ class CitySolingenDocument extends ContributionDocument
|
||||||
return $firstRow . "\n" . $secondRow;
|
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
|
public function getEngine(): Engine
|
||||||
{
|
{
|
||||||
return Engine::PDFLATEX;
|
return Engine::PDFLATEX;
|
||||||
|
@ -81,7 +111,7 @@ class CitySolingenDocument extends ContributionDocument
|
||||||
|
|
||||||
public static function getName(): string
|
public static function getName(): string
|
||||||
{
|
{
|
||||||
return 'Stadt Solingen';
|
return 'Für Stadt Solingen erstellen';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,17 +123,7 @@ class CitySolingenDocument extends ContributionDocument
|
||||||
'dateFrom' => 'required|string|date_format:Y-m-d',
|
'dateFrom' => 'required|string|date_format:Y-m-d',
|
||||||
'dateUntil' => 'required|string|date_format:Y-m-d',
|
'dateUntil' => 'required|string|date_format:Y-m-d',
|
||||||
'zipLocation' => 'required|string',
|
'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,23 +2,21 @@
|
||||||
|
|
||||||
namespace App\Contribution\Documents;
|
namespace App\Contribution\Documents;
|
||||||
|
|
||||||
use App\Contribution\Contracts\HasContributionData;
|
|
||||||
use App\Form\Enums\SpecialType;
|
|
||||||
use Zoomyboy\Tex\Document;
|
use Zoomyboy\Tex\Document;
|
||||||
use Zoomyboy\Tex\Template;
|
|
||||||
|
|
||||||
abstract class ContributionDocument extends Document
|
abstract class ContributionDocument extends Document
|
||||||
{
|
{
|
||||||
private string $eventName;
|
|
||||||
|
|
||||||
abstract public static function getName(): string;
|
abstract public static function getName(): string;
|
||||||
|
|
||||||
abstract public static function fromPayload(HasContributionData $request): self;
|
/**
|
||||||
|
* @param ContributionRequestArray $request
|
||||||
|
*/
|
||||||
|
abstract public static function fromRequest(array $request): self;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<int, SpecialType>
|
* @param ContributionApiRequestArray $request
|
||||||
*/
|
*/
|
||||||
abstract public static function requiredFormSpecialTypes(): array;
|
abstract public static function fromApiRequest(array $request): self;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<string, mixed>
|
* @return array<string, mixed>
|
||||||
|
@ -31,29 +29,8 @@ abstract class ContributionDocument extends Document
|
||||||
public static function globalRules(): array
|
public static function globalRules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'eventName' => 'required|string',
|
|
||||||
'members' => 'present|array|min:1',
|
'members' => 'present|array|min:1',
|
||||||
'members.*' => 'integer|exists:members,id',
|
'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,45 +2,61 @@
|
||||||
|
|
||||||
namespace App\Contribution\Documents;
|
namespace App\Contribution\Documents;
|
||||||
|
|
||||||
use App\Contribution\Contracts\HasContributionData;
|
|
||||||
use App\Contribution\Data\MemberData;
|
use App\Contribution\Data\MemberData;
|
||||||
use App\Contribution\Traits\FormatsDates;
|
|
||||||
use App\Contribution\Traits\HasPdfBackground;
|
|
||||||
use App\Country;
|
use App\Country;
|
||||||
use App\Form\Enums\SpecialType;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Zoomyboy\Tex\Engine;
|
||||||
|
use Zoomyboy\Tex\Template;
|
||||||
|
|
||||||
class RdpNrwDocument extends ContributionDocument
|
class RdpNrwDocument extends ContributionDocument
|
||||||
{
|
{
|
||||||
use HasPdfBackground;
|
|
||||||
use FormatsDates;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Collection<int, Collection<int, MemberData>> $members
|
* @param Collection<int, Collection<int, MemberData>> $members
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public Carbon $dateFrom,
|
public string $dateFrom,
|
||||||
public Carbon $dateUntil,
|
public string $dateUntil,
|
||||||
public string $zipLocation,
|
public string $zipLocation,
|
||||||
public ?Country $country,
|
public ?Country $country,
|
||||||
public Collection $members,
|
public Collection $members,
|
||||||
public ?string $filename = '',
|
public ?string $filename = '',
|
||||||
public string $type = 'F',
|
public string $type = 'F',
|
||||||
public string $eventName = '',
|
|
||||||
) {
|
) {
|
||||||
$this->setEventName($eventName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function fromPayload(HasContributionData $request): self
|
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
|
||||||
{
|
{
|
||||||
return new self(
|
return new self(
|
||||||
dateFrom: $request->dateFrom(),
|
dateFrom: $request['dateFrom'],
|
||||||
dateUntil: $request->dateUntil(),
|
dateUntil: $request['dateUntil'],
|
||||||
zipLocation: $request->zipLocation(),
|
zipLocation: $request['zipLocation'],
|
||||||
country: $request->country(),
|
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||||
members: $request->members()->chunk(17),
|
members: MemberData::fromModels($request['members'])->chunk(17),
|
||||||
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(17),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,9 +65,65 @@ class RdpNrwDocument extends ContributionDocument
|
||||||
return $this->country->name;
|
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
|
public static function getName(): string
|
||||||
{
|
{
|
||||||
return 'RdP NRW';
|
return 'Für RdP NRW erstellen';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,17 +136,7 @@ class RdpNrwDocument extends ContributionDocument
|
||||||
'dateUntil' => 'required|string|date_format:Y-m-d',
|
'dateUntil' => 'required|string|date_format:Y-m-d',
|
||||||
'country' => 'required|integer|exists:countries,id',
|
'country' => 'required|integer|exists:countries,id',
|
||||||
'zipLocation' => 'required|string',
|
'zipLocation' => 'required|string',
|
||||||
];
|
'eventName' => 'required|string',
|
||||||
}
|
|
||||||
|
|
||||||
public static function requiredFormSpecialTypes(): array {
|
|
||||||
return [
|
|
||||||
SpecialType::FIRSTNAME,
|
|
||||||
SpecialType::LASTNAME,
|
|
||||||
SpecialType::BIRTHDAY,
|
|
||||||
SpecialType::ZIP,
|
|
||||||
SpecialType::LOCATION,
|
|
||||||
SpecialType::GENDER,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,76 +0,0 @@
|
||||||
<?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,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,256 +0,0 @@
|
||||||
<?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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
<?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'));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,68 +0,0 @@
|
||||||
<?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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
<?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()]);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Contribution\Traits;
|
|
||||||
|
|
||||||
use Zoomyboy\Tex\Engine;
|
|
||||||
|
|
||||||
trait HasPdfBackground
|
|
||||||
{
|
|
||||||
public function getEngine(): Engine
|
|
||||||
{
|
|
||||||
return Engine::PDFLATEX;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,13 +3,11 @@
|
||||||
namespace App;
|
namespace App;
|
||||||
|
|
||||||
use App\Nami\HasNamiField;
|
use App\Nami\HasNamiField;
|
||||||
use Database\Factories\CountryFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class Country extends Model
|
class Country extends Model
|
||||||
{
|
{
|
||||||
/** @use HasFactory<CountryFactory> */
|
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
use HasNamiField;
|
use HasNamiField;
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,11 @@
|
||||||
namespace App\Course\Models;
|
namespace App\Course\Models;
|
||||||
|
|
||||||
use App\Nami\HasNamiField;
|
use App\Nami\HasNamiField;
|
||||||
use Database\Factories\Course\Models\CourseFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class Course extends Model
|
class Course extends Model
|
||||||
{
|
{
|
||||||
/** @use HasFactory<CourseFactory> */
|
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
use HasNamiField;
|
use HasNamiField;
|
||||||
|
|
||||||
|
|
|
@ -3,21 +3,19 @@
|
||||||
namespace App\Course\Models;
|
namespace App\Course\Models;
|
||||||
|
|
||||||
use App\Member\Member;
|
use App\Member\Member;
|
||||||
use Database\Factories\Course\Models\CourseMemberFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
class CourseMember extends Model
|
class CourseMember extends Model
|
||||||
{
|
{
|
||||||
/** @use HasFactory<CourseMemberFactory> */
|
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
/** @var array<int, string> */
|
/** @var array<int, string> */
|
||||||
public $guarded = [];
|
public $guarded = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return BelongsTo<Course, $this>
|
* @return BelongsTo<Course, self>
|
||||||
*/
|
*/
|
||||||
public function course(): BelongsTo
|
public function course(): BelongsTo
|
||||||
{
|
{
|
||||||
|
@ -25,7 +23,7 @@ class CourseMember extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return BelongsTo<Member, $this>
|
* @return BelongsTo<Member, self>
|
||||||
*/
|
*/
|
||||||
public function member(): BelongsTo
|
public function member(): BelongsTo
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
namespace App\Dashboard;
|
namespace App\Dashboard;
|
||||||
|
|
||||||
use Illuminate\Routing\Router;
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use App\Dashboard\Actions\IndexAction as DashboardIndexAction;
|
|
||||||
|
|
||||||
class DashboardServiceProvider extends ServiceProvider
|
class DashboardServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
@ -25,8 +23,5 @@ class DashboardServiceProvider extends ServiceProvider
|
||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
app(Router::class)->middleware(['web', 'auth:web'])->group(function ($router) {
|
|
||||||
$router->get('/', DashboardIndexAction::class)->name('home');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,9 @@ use Sabre\CardDAV\Backend\AbstractBackend;
|
||||||
use Sabre\DAV\PropPatch;
|
use Sabre\DAV\PropPatch;
|
||||||
use Sabre\VObject\Component\VCard;
|
use Sabre\VObject\Component\VCard;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template M as array{lastmodified: int, etag: string, uri: string, id: int, size: int}
|
||||||
|
*/
|
||||||
class AddressBookBackend extends AbstractBackend
|
class AddressBookBackend extends AbstractBackend
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -112,7 +115,7 @@ class AddressBookBackend extends AbstractBackend
|
||||||
*
|
*
|
||||||
* @param mixed $addressbookId
|
* @param mixed $addressbookId
|
||||||
*
|
*
|
||||||
* @return array<int, AddressBookCard>
|
* @return array<int, M>
|
||||||
*/
|
*/
|
||||||
public function getCards($addressbookId): array
|
public function getCards($addressbookId): array
|
||||||
{
|
{
|
||||||
|
@ -130,7 +133,7 @@ class AddressBookBackend extends AbstractBackend
|
||||||
* @param mixed $addressBookId
|
* @param mixed $addressBookId
|
||||||
* @param string $cardUri
|
* @param string $cardUri
|
||||||
*
|
*
|
||||||
* @return AddressBookCard|bool
|
* @return M
|
||||||
*/
|
*/
|
||||||
public function getCard($addressBookId, $cardUri)
|
public function getCard($addressBookId, $cardUri)
|
||||||
{
|
{
|
||||||
|
@ -155,9 +158,8 @@ class AddressBookBackend extends AbstractBackend
|
||||||
* If the backend supports this, it may allow for some speed-ups.
|
* If the backend supports this, it may allow for some speed-ups.
|
||||||
*
|
*
|
||||||
* @param mixed $addressBookId
|
* @param mixed $addressBookId
|
||||||
* @param array<int, string> $uris
|
|
||||||
*
|
*
|
||||||
* @return array<int, mixed>
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getMultipleCards($addressBookId, array $uris)
|
public function getMultipleCards($addressBookId, array $uris)
|
||||||
{
|
{
|
||||||
|
@ -246,7 +248,7 @@ class AddressBookBackend extends AbstractBackend
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return AddressBookCard
|
* @return M
|
||||||
*/
|
*/
|
||||||
private function cardMeta(Member $member): array
|
private function cardMeta(Member $member): array
|
||||||
{
|
{
|
||||||
|
|
|
@ -129,7 +129,6 @@ class Principal implements PrincipalBackendInterface
|
||||||
*/
|
*/
|
||||||
public function findByUri($uri, $principalPrefix)
|
public function findByUri($uri, $principalPrefix)
|
||||||
{
|
{
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -137,11 +136,10 @@ class Principal implements PrincipalBackendInterface
|
||||||
*
|
*
|
||||||
* @param string $principal
|
* @param string $principal
|
||||||
*
|
*
|
||||||
* @return array<int, string>|null
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getGroupMemberSet($principal)
|
public function getGroupMemberSet($principal)
|
||||||
{
|
{
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,7 +147,7 @@ class Principal implements PrincipalBackendInterface
|
||||||
*
|
*
|
||||||
* @param string $principal
|
* @param string $principal
|
||||||
*
|
*
|
||||||
* @return array<int, string>|null
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getGroupMembership($principal)
|
public function getGroupMembership($principal)
|
||||||
{
|
{
|
||||||
|
@ -157,7 +155,7 @@ class Principal implements PrincipalBackendInterface
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['addressbooks/' . $matches[1]];
|
return ['addressbooks/'.$matches[1]];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -166,8 +164,6 @@ class Principal implements PrincipalBackendInterface
|
||||||
* The principals should be passed as a list of uri's.
|
* The principals should be passed as a list of uri's.
|
||||||
*
|
*
|
||||||
* @param string $principal
|
* @param string $principal
|
||||||
* @param array<int, string> $members
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setGroupMemberSet($principal, array $members)
|
public function setGroupMemberSet($principal, array $members)
|
||||||
{
|
{
|
||||||
|
@ -179,8 +175,8 @@ class Principal implements PrincipalBackendInterface
|
||||||
private function userToPrincipal(User $user): array
|
private function userToPrincipal(User $user): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'{DAV:}displayname' => $user->firstname . ' ' . $user->lastname,
|
'{DAV:}displayname' => $user->name,
|
||||||
'uri' => 'principals/' . $user->email,
|
'uri' => 'principals/'.$user->email,
|
||||||
'{http://sabredav.org/ns}email-address' => $user->email,
|
'{http://sabredav.org/ns}email-address' => $user->email,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ use Sabre\CardDAV\AddressBookRoot;
|
||||||
use Sabre\CardDAV\Plugin as CardDAVPlugin;
|
use Sabre\CardDAV\Plugin as CardDAVPlugin;
|
||||||
use Sabre\DAV\Auth\Plugin as AuthPlugin;
|
use Sabre\DAV\Auth\Plugin as AuthPlugin;
|
||||||
use Sabre\DAV\Browser\Plugin as BrowserPlugin;
|
use Sabre\DAV\Browser\Plugin as BrowserPlugin;
|
||||||
use Sabre\DAV\ServerPlugin;
|
|
||||||
use Sabre\DAVACL\AbstractPrincipalCollection;
|
use Sabre\DAVACL\AbstractPrincipalCollection;
|
||||||
use Sabre\DAVACL\Plugin as AclPlugin;
|
use Sabre\DAVACL\Plugin as AclPlugin;
|
||||||
use Sabre\DAVACL\PrincipalCollection;
|
use Sabre\DAVACL\PrincipalCollection;
|
||||||
|
@ -51,9 +50,6 @@ class ServiceProvider extends BaseServiceProvider
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<int, ServerPlugin>
|
|
||||||
*/
|
|
||||||
private function plugins(): array
|
private function plugins(): array
|
||||||
{
|
{
|
||||||
$authBackend = new AuthBackend();
|
$authBackend = new AuthBackend();
|
||||||
|
|
|
@ -19,7 +19,7 @@ class EfzPendingBlock extends Block
|
||||||
})
|
})
|
||||||
->whereCurrentGroup()
|
->whereCurrentGroup()
|
||||||
->orderByRaw('lastname, firstname')
|
->orderByRaw('lastname, firstname')
|
||||||
->whereHas('memberships', fn ($builder) => $builder->isLeader()->active());
|
->whereHas('memberships', fn ($builder) => $builder->isLeader());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,14 +12,15 @@ class Handler extends ExceptionHandler
|
||||||
/**
|
/**
|
||||||
* A list of the exception types that are not reported.
|
* A list of the exception types that are not reported.
|
||||||
*
|
*
|
||||||
* @var array<int, class-string<Throwable>>
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
protected $dontReport = [];
|
protected $dontReport = [
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of the inputs that are never flashed for validation exceptions.
|
* A list of the inputs that are never flashed for validation exceptions.
|
||||||
*
|
*
|
||||||
* @var array<int, string>
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
protected $dontFlash = [
|
protected $dontFlash = [
|
||||||
'password',
|
'password',
|
||||||
|
|
|
@ -4,24 +4,23 @@ namespace App;
|
||||||
|
|
||||||
use App\Nami\HasNamiField;
|
use App\Nami\HasNamiField;
|
||||||
use App\Payment\Subscription;
|
use App\Payment\Subscription;
|
||||||
use Database\Factories\FeeFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
class Fee extends Model
|
class Fee extends Model
|
||||||
{
|
{
|
||||||
/** @use HasFactory<FeeFactory> */
|
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
use HasNamiField;
|
use HasNamiField;
|
||||||
|
|
||||||
|
/** @var array<int, string> */
|
||||||
public $fillable = ['name', 'nami_id'];
|
public $fillable = ['name', 'nami_id'];
|
||||||
|
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return HasMany<Subscription, $this>
|
* @return HasMany<Subscription>
|
||||||
*/
|
*/
|
||||||
public function subscriptions(): HasMany
|
public function subscriptions(): HasMany
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Fileshare\Actions;
|
|
||||||
|
|
||||||
use App\Fileshare\Models\Fileshare;
|
|
||||||
use App\Fileshare\Resources\FileshareResource;
|
|
||||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
|
||||||
|
|
||||||
class FileshareApiIndexAction
|
|
||||||
{
|
|
||||||
use AsAction;
|
|
||||||
|
|
||||||
public function handle(): AnonymousResourceCollection
|
|
||||||
{
|
|
||||||
session()->put('menu', 'setting');
|
|
||||||
session()->put('title', 'Datei-Verbindungen');
|
|
||||||
|
|
||||||
return FileshareResource::collection(Fileshare::paginate(15));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Fileshare\Actions;
|
|
||||||
|
|
||||||
use App\Fileshare\Models\Fileshare;
|
|
||||||
use App\Lib\Events\Succeeded;
|
|
||||||
use Illuminate\Validation\ValidationException;
|
|
||||||
use Lorisleiva\Actions\ActionRequest;
|
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
|
||||||
|
|
||||||
class FileshareStoreAction
|
|
||||||
{
|
|
||||||
use AsAction;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function rules(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'name' => 'required|string|max:255',
|
|
||||||
'type' => 'required|string|max:255|exclude',
|
|
||||||
'config' => 'array|exclude',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function asController(ActionRequest $request): void
|
|
||||||
{
|
|
||||||
$type = $request->input('type')::from($request->input('config'));
|
|
||||||
|
|
||||||
if (!$type->check()) {
|
|
||||||
throw ValidationException::withMessages(['type' => 'Verbindung fehlgeschlagen']);
|
|
||||||
}
|
|
||||||
|
|
||||||
Fileshare::create([
|
|
||||||
...$request->validated(),
|
|
||||||
'type' => $type,
|
|
||||||
]);
|
|
||||||
|
|
||||||
Succeeded::message('Verbindung erstellt.')->dispatch();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Fileshare\Actions;
|
|
||||||
|
|
||||||
use App\Fileshare\Models\Fileshare;
|
|
||||||
use App\Lib\Events\Succeeded;
|
|
||||||
use Illuminate\Validation\ValidationException;
|
|
||||||
use Lorisleiva\Actions\ActionRequest;
|
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
|
||||||
|
|
||||||
class FileshareUpdateAction
|
|
||||||
{
|
|
||||||
use AsAction;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function rules(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'name' => 'required|string|max:255',
|
|
||||||
'type' => 'required|string|max:255|exclude',
|
|
||||||
'config' => 'array|exclude',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle(ActionRequest $request, Fileshare $fileshare): void
|
|
||||||
{
|
|
||||||
$type = $request->input('type')::from($request->input('config'));
|
|
||||||
|
|
||||||
if (!$type->check()) {
|
|
||||||
throw ValidationException::withMessages(['type' => 'Verbindung fehlgeschlagen']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$fileshare->update([
|
|
||||||
...$request->validated(),
|
|
||||||
'type' => $type,
|
|
||||||
]);
|
|
||||||
|
|
||||||
Succeeded::message('Verbindung bearbeitet.')->dispatch();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Fileshare\Actions;
|
|
||||||
|
|
||||||
use App\Fileshare\Data\ResourceData;
|
|
||||||
use App\Fileshare\Models\Fileshare;
|
|
||||||
use Lorisleiva\Actions\ActionRequest;
|
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
|
||||||
use Spatie\LaravelData\DataCollection;
|
|
||||||
|
|
||||||
class ListFilesAction
|
|
||||||
{
|
|
||||||
use AsAction;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return DataCollection<int, ResourceData>
|
|
||||||
*/
|
|
||||||
public function handle(ActionRequest $request, Fileshare $fileshare): DataCollection
|
|
||||||
{
|
|
||||||
return ResourceData::collect($fileshare->type->getSubDirectories($request->input('parent')), DataCollection::class)->wrap('data');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,57 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Fileshare\ConnectionTypes;
|
|
||||||
|
|
||||||
use Illuminate\Filesystem\FilesystemAdapter;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Spatie\LaravelData\Data;
|
|
||||||
|
|
||||||
abstract class ConnectionType extends Data
|
|
||||||
{
|
|
||||||
abstract public function check(): bool;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
abstract public static function defaults(): array;
|
|
||||||
|
|
||||||
abstract public static function title(): string;
|
|
||||||
|
|
||||||
abstract public function getFilesystem(): FilesystemAdapter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<int, array{label: string, key: string, type: string}>
|
|
||||||
*/
|
|
||||||
abstract public static function fields(): array;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<int, mixed>
|
|
||||||
*/
|
|
||||||
public static function forSelect(): array
|
|
||||||
{
|
|
||||||
return self::types()
|
|
||||||
->map(fn ($file) => ['id' => $file, 'name' => $file::title(), 'defaults' => $file::defaults(), 'fields' => $file::fields()])
|
|
||||||
->toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<int, string>
|
|
||||||
*/
|
|
||||||
public function getSubDirectories(?string $parent): array
|
|
||||||
{
|
|
||||||
$filesystem = $this->getFilesystem();
|
|
||||||
|
|
||||||
return $filesystem->directories($parent ?: '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection<int, class-string<ConnectionType>>
|
|
||||||
*/
|
|
||||||
private static function types(): Collection
|
|
||||||
{
|
|
||||||
return collect(glob(base_path('app/Fileshare/ConnectionTypes/*')))
|
|
||||||
->map(fn ($file) => 'App\\Fileshare\\ConnectionTypes\\' . pathinfo($file, PATHINFO_FILENAME))
|
|
||||||
->filter(fn ($file) => $file !== static::class)
|
|
||||||
->values();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Fileshare\ConnectionTypes;
|
|
||||||
|
|
||||||
use Illuminate\Filesystem\FilesystemAdapter;
|
|
||||||
use Illuminate\Http\Client\ConnectionException;
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use League\Flysystem\Filesystem;
|
|
||||||
use League\Flysystem\WebDAV\WebDAVAdapter;
|
|
||||||
use Sabre\DAV\Client;
|
|
||||||
|
|
||||||
class NextcloudConnection extends OwncloudConnection
|
|
||||||
{
|
|
||||||
|
|
||||||
public function check(): bool
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$response = Http::withoutVerifying()
|
|
||||||
->withBasicAuth($this->user, $this->password)
|
|
||||||
->withHeaders(['OCS-APIRequest' => 'true'])
|
|
||||||
->acceptJson()
|
|
||||||
->get($this->baseUrl . '/ocs/v2.php/cloud/capabilities');
|
|
||||||
return $response->ok();
|
|
||||||
} catch (ConnectionException $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function title(): string
|
|
||||||
{
|
|
||||||
return 'Nextcloud';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFilesystem(): FilesystemAdapter
|
|
||||||
{
|
|
||||||
$adapter = new WebDAVAdapter(new Client([
|
|
||||||
'baseUri' => $this->baseUrl . '/remote.php/dav/files/' . $this->user,
|
|
||||||
'userName' => $this->user,
|
|
||||||
'password' => $this->password,
|
|
||||||
]), '/remote.php/dav/files/' . $this->user);
|
|
||||||
|
|
||||||
return new FilesystemAdapter(new Filesystem($adapter), $adapter);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,76 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Fileshare\ConnectionTypes;
|
|
||||||
|
|
||||||
use Illuminate\Filesystem\FilesystemAdapter;
|
|
||||||
use Illuminate\Http\Client\ConnectionException;
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use League\Flysystem\Filesystem;
|
|
||||||
use League\Flysystem\WebDAV\WebDAVAdapter;
|
|
||||||
use Sabre\DAV\Client;
|
|
||||||
use Spatie\LaravelData\Attributes\MapInputName;
|
|
||||||
use Spatie\LaravelData\Attributes\MapOutputName;
|
|
||||||
use Spatie\LaravelData\Mappers\SnakeCaseMapper;
|
|
||||||
|
|
||||||
#[MapInputName(SnakeCaseMapper::class)]
|
|
||||||
#[MapOutputName(SnakeCaseMapper::class)]
|
|
||||||
class OwncloudConnection extends ConnectionType
|
|
||||||
{
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
public string $user,
|
|
||||||
public string $password,
|
|
||||||
public string $baseUrl,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public function check(): bool
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$response = Http::withoutVerifying()->withBasicAuth($this->user, $this->password)->acceptJson()->get($this->baseUrl . '/ocs/v1.php/cloud/capabilities?format=json');
|
|
||||||
return $response->ok();
|
|
||||||
} catch (ConnectionException $e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public static function defaults(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'user' => '',
|
|
||||||
'password' => '',
|
|
||||||
'base_url' => '',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function title(): string
|
|
||||||
{
|
|
||||||
return 'Owncloud';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public static function fields(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
['label' => 'URL', 'key' => 'base_url', 'type' => 'text'],
|
|
||||||
['label' => 'Benutzer', 'key' => 'user', 'type' => 'text'],
|
|
||||||
['label' => 'Passwort', 'key' => 'password', 'type' => 'password'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFilesystem(): FilesystemAdapter
|
|
||||||
{
|
|
||||||
$adapter = new WebDAVAdapter(new Client([
|
|
||||||
'baseUri' => $this->baseUrl . '/remote.php/dav/files/' . $this->user,
|
|
||||||
'userName' => $this->user,
|
|
||||||
'password' => $this->password,
|
|
||||||
]), '/remote.php/dav/files/' . $this->user);
|
|
||||||
|
|
||||||
return new FilesystemAdapter(new Filesystem($adapter), $adapter);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Fileshare\Data;
|
|
||||||
|
|
||||||
use App\Fileshare\Models\Fileshare;
|
|
||||||
use Illuminate\Filesystem\FilesystemAdapter;
|
|
||||||
use Spatie\LaravelData\Attributes\MapInputName;
|
|
||||||
use Spatie\LaravelData\Attributes\MapOutputName;
|
|
||||||
use Spatie\LaravelData\Data;
|
|
||||||
use Spatie\LaravelData\Mappers\SnakeCaseMapper;
|
|
||||||
|
|
||||||
#[MapInputName(SnakeCaseMapper::class)]
|
|
||||||
#[MapOutputName(SnakeCaseMapper::class)]
|
|
||||||
class FileshareResourceData extends Data
|
|
||||||
{
|
|
||||||
|
|
||||||
public function __construct(public int $connectionId, public string $resource)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getConnection(): Fileshare
|
|
||||||
{
|
|
||||||
return Fileshare::find($this->connectionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getStorage(): FilesystemAdapter
|
|
||||||
{
|
|
||||||
return $this->getConnection()->type->getFilesystem();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Fileshare\Data;
|
|
||||||
|
|
||||||
use Spatie\LaravelData\Data;
|
|
||||||
|
|
||||||
class ResourceData extends Data
|
|
||||||
{
|
|
||||||
|
|
||||||
public function __construct(public string $name, public string $path, public string $parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function fromString(string $path): self
|
|
||||||
{
|
|
||||||
$dir = '/' . trim($path, '\\/');
|
|
||||||
|
|
||||||
return self::from([
|
|
||||||
'path' => $dir,
|
|
||||||
'name' => pathinfo($dir, PATHINFO_BASENAME),
|
|
||||||
'parent' => pathinfo($dir, PATHINFO_DIRNAME),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Fileshare;
|
|
||||||
|
|
||||||
use App\Fileshare\Models\Fileshare;
|
|
||||||
use App\Fileshare\Resources\FileshareResource;
|
|
||||||
use App\Setting\LocalSettings;
|
|
||||||
|
|
||||||
class FileshareSettings extends LocalSettings
|
|
||||||
{
|
|
||||||
public static function group(): string
|
|
||||||
{
|
|
||||||
return 'fileshare';
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function title(): string
|
|
||||||
{
|
|
||||||
return 'Datei-Verbindungen';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public function viewData(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'data' => FileshareResource::collection(Fileshare::paginate(15))
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
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 = [];
|
|
||||||
|
|
||||||
public $casts = [
|
|
||||||
'type' => ConnectionType::class,
|
|
||||||
];
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Fileshare\Resources;
|
|
||||||
|
|
||||||
use App\Fileshare\ConnectionTypes\ConnectionType;
|
|
||||||
use App\Fileshare\Models\Fileshare;
|
|
||||||
use App\Lib\HasMeta;
|
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @mixin Fileshare
|
|
||||||
*/
|
|
||||||
class FileshareResource extends JsonResource
|
|
||||||
{
|
|
||||||
|
|
||||||
use HasMeta;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Transform the resource into an array.
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function toArray($request)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'name' => $this->name,
|
|
||||||
'is_active' => $this->type->check(),
|
|
||||||
'type' => get_class($this->type),
|
|
||||||
'config' => $this->type->toArray(),
|
|
||||||
'id' => $this->id,
|
|
||||||
'type_human' => $this->type::title(),
|
|
||||||
'links' => [
|
|
||||||
'update' => route('fileshare.update', ['fileshare' => $this->getModel()]),
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public static function meta(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'default' => [
|
|
||||||
'name' => '',
|
|
||||||
'type' => null,
|
|
||||||
'config' => null,
|
|
||||||
],
|
|
||||||
'types' => ConnectionType::forSelect(),
|
|
||||||
'links' => [
|
|
||||||
'store' => route('fileshare.store'),
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -10,7 +10,7 @@ class ClearFrontendCacheAction
|
||||||
{
|
{
|
||||||
use AsAction;
|
use AsAction;
|
||||||
|
|
||||||
public function handle(): void
|
public function handle()
|
||||||
{
|
{
|
||||||
Http::get(app(FormSettings::class)->clearCacheUrl);
|
Http::get(app(FormSettings::class)->clearCacheUrl);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,71 +0,0 @@
|
||||||
<?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,14 +15,22 @@ class ExportAction
|
||||||
|
|
||||||
public function handle(Form $form): string
|
public function handle(Form $form): string
|
||||||
{
|
{
|
||||||
return CreateExcelDocumentAction::run($form, $form->participants);
|
$csv = Writer::createFromString();
|
||||||
|
|
||||||
|
$csv->insertOne($form->getFields()->names());
|
||||||
|
|
||||||
|
foreach ($form->participants as $participant) {
|
||||||
|
$csv->insertOne($participant->getFields()->presentValues());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $csv->toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function asController(Form $form, ActionRequest $request): StreamedResponse
|
public function asController(Form $form, ActionRequest $request): StreamedResponse
|
||||||
{
|
{
|
||||||
$contents = $this->handle($form);
|
$contents = $this->handle($form);
|
||||||
|
|
||||||
$filename = 'tn-' . $form->slug . '.xlsx';
|
$filename = 'tn-' . $form->slug . '.csv';
|
||||||
Storage::disk('temp')->put($filename, $contents);
|
Storage::disk('temp')->put($filename, $contents);
|
||||||
|
|
||||||
return Storage::disk('temp')->download($filename);
|
return Storage::disk('temp')->download($filename);
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Form\Actions;
|
|
||||||
|
|
||||||
use App\Form\Models\Form;
|
|
||||||
use App\Group;
|
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
|
||||||
|
|
||||||
class ExportSyncAction
|
|
||||||
{
|
|
||||||
use AsAction;
|
|
||||||
|
|
||||||
public Form $form;
|
|
||||||
|
|
||||||
public function handle(Form $form): void
|
|
||||||
{
|
|
||||||
if (!$form->export->root) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$storage = $form->export->root->getStorage();
|
|
||||||
|
|
||||||
$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) {
|
|
||||||
$group = Group::find($groupId);
|
|
||||||
if (!$group?->fileshare) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$group->fileshare->getStorage()->put($group->fileshare->resource . '/Anmeldungen ' . $form->name . '.xlsx', CreateExcelDocumentAction::run($form, $participants));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function asJob(int $formId): void
|
|
||||||
{
|
|
||||||
$this->handle(Form::find($formId));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -16,7 +16,7 @@ class FormApiListAction
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $filter
|
* @param string $filter
|
||||||
* @return LengthAwarePaginator<int, Form>
|
* @return LengthAwarePaginator<Form>
|
||||||
*/
|
*/
|
||||||
public function handle(string $filter, int $perPage): LengthAwarePaginator
|
public function handle(string $filter, int $perPage): LengthAwarePaginator
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ class FormApiListAction
|
||||||
{
|
{
|
||||||
return FormApiResource::collection($this->handle(
|
return FormApiResource::collection($this->handle(
|
||||||
$request->input('filter', ''),
|
$request->input('filter', ''),
|
||||||
$request->input('perPage', 9999)
|
$request->input('perPage', 10)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
<?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([]);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Form\Actions;
|
|
||||||
|
|
||||||
use App\Form\FormSettings;
|
|
||||||
use App\Form\Models\Form;
|
|
||||||
use Illuminate\Support\Facades\Cache;
|
|
||||||
use Illuminate\Support\Facades\URL;
|
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
|
||||||
|
|
||||||
class FormGenerateLaterlinkAction
|
|
||||||
{
|
|
||||||
use AsAction;
|
|
||||||
|
|
||||||
public function asController(Form $form)
|
|
||||||
{
|
|
||||||
$registerUrl = str(app(FormSettings::class)->registerUrl)->replace('{slug}', $form->slug)->toString();
|
|
||||||
$laterId = str()->uuid()->toString();
|
|
||||||
$laterUrl = URL::signedRoute('form.register', ['form' => $form, 'later' => '1', 'id' => $laterId]);
|
|
||||||
$urlParts = parse_url($laterUrl);
|
|
||||||
|
|
||||||
Cache::remember('later_'.$laterId, 2592000, fn () => $form->id); // Link ist 40 Tage gültig
|
|
||||||
|
|
||||||
return response()->json([
|
|
||||||
'url' => $registerUrl.'?'.data_get($urlParts, 'query')
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -16,7 +16,7 @@ class FormIndexAction
|
||||||
use AsAction;
|
use AsAction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return LengthAwarePaginator<int, Form>
|
* @return LengthAwarePaginator<Form>
|
||||||
*/
|
*/
|
||||||
public function handle(string $filter): LengthAwarePaginator
|
public function handle(string $filter): LengthAwarePaginator
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,18 +28,12 @@ class FormStoreAction
|
||||||
'to' => 'required|date',
|
'to' => 'required|date',
|
||||||
'registration_from' => 'present|nullable|date',
|
'registration_from' => 'present|nullable|date',
|
||||||
'registration_until' => 'present|nullable|date',
|
'registration_until' => 'present|nullable|date',
|
||||||
|
'mail_top' => 'array',
|
||||||
|
'mail_bottom' => 'array',
|
||||||
'header_image' => 'required|exclude',
|
'header_image' => 'required|exclude',
|
||||||
'mailattachments' => 'present|array|exclude',
|
'mailattachments' => 'present|array|exclude',
|
||||||
'is_active' => 'boolean',
|
'is_active' => 'boolean',
|
||||||
'is_private' => 'boolean',
|
'is_private' => 'boolean',
|
||||||
'export' => 'nullable|array',
|
|
||||||
'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',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,16 +29,10 @@ class FormUpdateAction
|
||||||
'to' => 'required|date',
|
'to' => 'required|date',
|
||||||
'registration_from' => 'present|nullable|date',
|
'registration_from' => 'present|nullable|date',
|
||||||
'registration_until' => 'present|nullable|date',
|
'registration_until' => 'present|nullable|date',
|
||||||
|
'mail_top' => 'array',
|
||||||
|
'mail_bottom' => 'array',
|
||||||
'is_active' => 'boolean',
|
'is_active' => 'boolean',
|
||||||
'is_private' => 'boolean',
|
'is_private' => 'boolean',
|
||||||
'export' => 'nullable|array',
|
|
||||||
'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 [
|
return [
|
||||||
'sorting' => 'array',
|
'sorting' => 'array',
|
||||||
'sorting.by' => 'required|string',
|
'sorting.0' => 'required|string',
|
||||||
'sorting.direction' => 'required|boolean',
|
'sorting.1' => 'required|string|in:asc,desc',
|
||||||
'active_columns' => 'array',
|
'active_columns' => 'array',
|
||||||
'active_columns.*' => ['string', Rule::in([...$form->getFields()->pluck('key')->toArray(), 'created_at', 'prevention'])]
|
'active_columns.*' => ['string', Rule::in([...$form->getFields()->pluck('key')->toArray(), 'created_at'])]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ class FormtemplateIndexAction
|
||||||
use AsAction;
|
use AsAction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return LengthAwarePaginator<int, Formtemplate>
|
* @return LengthAwarePaginator<Formtemplate>
|
||||||
*/
|
*/
|
||||||
public function handle(): LengthAwarePaginator
|
public function handle(): LengthAwarePaginator
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
<?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()],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -18,7 +18,6 @@ trait HasValidation
|
||||||
'name' => 'required|string|max:255',
|
'name' => 'required|string|max:255',
|
||||||
'config' => 'array',
|
'config' => 'array',
|
||||||
'config.sections.*.name' => 'required',
|
'config.sections.*.name' => 'required',
|
||||||
'config.sections.*.intro' => 'nullable|string',
|
|
||||||
'config.sections.*.fields' => 'array',
|
'config.sections.*.fields' => 'array',
|
||||||
'config.sections.*.fields.*.name' => 'required|string',
|
'config.sections.*.fields.*.name' => 'required|string',
|
||||||
'config.sections.*.fields.*.type' => ['required', 'string', Rule::in(array_column(Field::asMeta(), 'id'))],
|
'config.sections.*.fields.*.type' => ['required', 'string', Rule::in(array_column(Field::asMeta(), 'id'))],
|
||||||
|
@ -28,8 +27,6 @@ trait HasValidation
|
||||||
'config.sections.*.fields.*.columns.mobile' => 'required|numeric|gt:0|lte:2',
|
'config.sections.*.fields.*.columns.mobile' => 'required|numeric|gt:0|lte:2',
|
||||||
'config.sections.*.fields.*.columns.tablet' => 'required|numeric|gt:0|lte:4',
|
'config.sections.*.fields.*.columns.tablet' => 'required|numeric|gt:0|lte:4',
|
||||||
'config.sections.*.fields.*.columns.desktop' => 'required|numeric|gt:0|lte:6',
|
'config.sections.*.fields.*.columns.desktop' => 'required|numeric|gt:0|lte:6',
|
||||||
'mail_top' => 'array',
|
|
||||||
'mail_bottom' => 'array',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Form\Actions;
|
|
||||||
|
|
||||||
use App\Form\Models\Participant;
|
|
||||||
use Lorisleiva\Actions\ActionRequest;
|
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
|
||||||
|
|
||||||
class ParticipantAssignAction
|
|
||||||
{
|
|
||||||
use AsAction;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function rules(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'member_id' => 'required|exists:members,id',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle(Participant $participant, ActionRequest $request): void
|
|
||||||
{
|
|
||||||
$participant->update(['member_id' => $request->input('member_id')]);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Form\Actions;
|
|
||||||
|
|
||||||
use App\Form\Models\Participant;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
|
||||||
|
|
||||||
class ParticipantFieldsAction
|
|
||||||
{
|
|
||||||
use AsAction;
|
|
||||||
|
|
||||||
public function handle(Participant $participant): JsonResponse
|
|
||||||
{
|
|
||||||
return response()->json([
|
|
||||||
'data' => [
|
|
||||||
'id' => $participant->id,
|
|
||||||
'config' => $participant->getConfig(),
|
|
||||||
]
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,7 +7,7 @@ use App\Form\Models\Participant;
|
||||||
use App\Form\Resources\ParticipantResource;
|
use App\Form\Resources\ParticipantResource;
|
||||||
use App\Form\Scopes\ParticipantFilterScope;
|
use App\Form\Scopes\ParticipantFilterScope;
|
||||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||||
use Laravel\Scout\Builder;
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
class ParticipantIndexAction
|
class ParticipantIndexAction
|
||||||
|
@ -15,24 +15,17 @@ class ParticipantIndexAction
|
||||||
use AsAction;
|
use AsAction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Builder<Participant>
|
* @return LengthAwarePaginator<Participant>
|
||||||
*/
|
*/
|
||||||
protected function getQuery(Form $form, ParticipantFilterScope $filter): Builder
|
public function handle(Form $form, ParticipantFilterScope $filter): LengthAwarePaginator
|
||||||
{
|
{
|
||||||
return $filter->setForm($form)->getQuery()
|
return $form->participants()->withFilter($filter)->with('form')->paginate(15);
|
||||||
->query(fn ($q) => $q->withCount('children')->with('form'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function asController(Form $form, ?int $parent = null): AnonymousResourceCollection
|
public function asController(Form $form): AnonymousResourceCollection
|
||||||
{
|
{
|
||||||
$filter = ParticipantFilterScope::fromRequest(request()->input('filter', ''))->parent($parent);
|
$filter = ParticipantFilterScope::fromRequest(request()->input('filter'));
|
||||||
|
return ParticipantResource::collection($this->handle($form, $filter))
|
||||||
$data = match ($parent) {
|
->additional(['meta' => ParticipantResource::meta($form)]);
|
||||||
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)]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Form\Actions;
|
|
||||||
|
|
||||||
use App\Form\Models\Form;
|
|
||||||
use App\Form\Models\Participant;
|
|
||||||
use App\Lib\Events\Succeeded;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Lorisleiva\Actions\ActionRequest;
|
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
|
||||||
|
|
||||||
class ParticipantStoreAction
|
|
||||||
{
|
|
||||||
use AsAction;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function rules(): array
|
|
||||||
{
|
|
||||||
/** @var Form */
|
|
||||||
$form = request()->route('form');
|
|
||||||
|
|
||||||
return $form->getRegistrationRules();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function getValidationAttributes(): array
|
|
||||||
{
|
|
||||||
/** @var Form */
|
|
||||||
$form = request()->route('form');
|
|
||||||
|
|
||||||
return $form->getRegistrationAttributes();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function getValidationMessages(): array
|
|
||||||
{
|
|
||||||
/** @var Form */
|
|
||||||
$form = request()->route('form');
|
|
||||||
|
|
||||||
return $form->getRegistrationMessages();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle(Form $form, ActionRequest $request): JsonResponse
|
|
||||||
{
|
|
||||||
$form->participants()->create(['data' => $request->validated()]);
|
|
||||||
ExportSyncAction::dispatch($form->id);
|
|
||||||
Succeeded::message('Teilnehmer*in erstellt.')->dispatch();
|
|
||||||
return response()->json([]);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Form\Actions;
|
|
||||||
|
|
||||||
use App\Form\Models\Participant;
|
|
||||||
use App\Lib\Events\Succeeded;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Lorisleiva\Actions\ActionRequest;
|
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
|
||||||
|
|
||||||
class ParticipantUpdateAction
|
|
||||||
{
|
|
||||||
use AsAction;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function rules(): array
|
|
||||||
{
|
|
||||||
/** @var Participant */
|
|
||||||
$participant = request()->route('participant');
|
|
||||||
|
|
||||||
return $participant->form->getRegistrationRules();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function getValidationAttributes(): array
|
|
||||||
{
|
|
||||||
/** @var Participant */
|
|
||||||
$participant = request()->route('participant');
|
|
||||||
|
|
||||||
return $participant->form->getRegistrationAttributes();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function getValidationMessages(): array
|
|
||||||
{
|
|
||||||
/** @var Participant */
|
|
||||||
$participant = request()->route('participant');
|
|
||||||
|
|
||||||
return $participant->form->getRegistrationMessages();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle(Participant $participant, ActionRequest $request): JsonResponse
|
|
||||||
{
|
|
||||||
$participant->update(['data' => [...$participant->data, ...$request->validated()]]);
|
|
||||||
ExportSyncAction::dispatch($participant->form->id);
|
|
||||||
Succeeded::message('Teilnehmer*in bearbeitet.')->dispatch();
|
|
||||||
return response()->json([]);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Form\Actions;
|
|
||||||
|
|
||||||
use App\Form\Editor\FormConditionResolver;
|
|
||||||
use App\Form\Models\Participant;
|
|
||||||
use App\Prevention\Mails\PreventionRememberMail;
|
|
||||||
use App\Prevention\PreventionSettings;
|
|
||||||
use Illuminate\Support\Facades\Mail;
|
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
|
||||||
|
|
||||||
class PreventionRememberAction
|
|
||||||
{
|
|
||||||
use AsAction;
|
|
||||||
|
|
||||||
public string $commandSignature = 'prevention:remember-forms';
|
|
||||||
|
|
||||||
public function handle(): void
|
|
||||||
{
|
|
||||||
$query = Participant::whereHas(
|
|
||||||
'form',
|
|
||||||
fn($form) => $form
|
|
||||||
->where('needs_prevention', true)
|
|
||||||
->where('from', '>=', now())
|
|
||||||
)
|
|
||||||
->where(
|
|
||||||
fn($q) => $q
|
|
||||||
->where('last_remembered_at', '<=', now()->subWeeks(2))
|
|
||||||
->orWhereNull('last_remembered_at')
|
|
||||||
);
|
|
||||||
foreach ($query->get() as $participant) {
|
|
||||||
if (!app(FormConditionResolver::class)->forParticipant($participant)->filterCondition($participant->form->prevention_conditions)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($participant->getFields()->getMailRecipient() === null || $participant->preventions()->count() === 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$body = app(PreventionSettings::class)->refresh()->formmail
|
|
||||||
->placeholder('formname', $participant->form->name)
|
|
||||||
->append($participant->form->prevention_text);
|
|
||||||
|
|
||||||
Mail::send(new PreventionRememberMail($participant, $body, $participant->preventions()));
|
|
||||||
|
|
||||||
$participant->update(['last_remembered_at' => now()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,10 +7,6 @@ use App\Form\Models\Form;
|
||||||
use App\Form\Models\Participant;
|
use App\Form\Models\Participant;
|
||||||
use App\Member\Member;
|
use App\Member\Member;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Support\Facades\Cache;
|
|
||||||
use Illuminate\Support\Facades\URL;
|
|
||||||
use Illuminate\Support\Facades\Validator;
|
|
||||||
use Illuminate\Validation\ValidationException;
|
|
||||||
use Lorisleiva\Actions\ActionRequest;
|
use Lorisleiva\Actions\ActionRequest;
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
|
@ -25,18 +21,17 @@ class RegisterAction
|
||||||
{
|
{
|
||||||
$memberQuery = FieldCollection::fromRequest($form, $input)
|
$memberQuery = FieldCollection::fromRequest($form, $input)
|
||||||
->withNamiType()
|
->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;
|
$mglnr = $form->getFields()->withNamiType()->count() && $memberQuery->count() === 1 ? $memberQuery->first()->mitgliedsnr : null;
|
||||||
|
|
||||||
$participant = $form->participants()->create([
|
$participant = $form->participants()->create([
|
||||||
'data' => $input,
|
'data' => $input,
|
||||||
'member_id' => $member?->id,
|
'mitgliedsnr' => $mglnr,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$form->getFields()->each(fn($field) => $field->afterRegistration($form, $participant, $input));
|
$form->getFields()->each(fn ($field) => $field->afterRegistration($form, $participant, $input));
|
||||||
|
|
||||||
$participant->sendConfirmationMail();
|
$participant->sendConfirmationMail();
|
||||||
ExportSyncAction::dispatch($form->id);
|
|
||||||
|
|
||||||
return $participant;
|
return $participant;
|
||||||
}
|
}
|
||||||
|
@ -76,34 +71,8 @@ class RegisterAction
|
||||||
|
|
||||||
public function asController(ActionRequest $request, Form $form): JsonResponse
|
public function asController(ActionRequest $request, Form $form): JsonResponse
|
||||||
{
|
{
|
||||||
if (!$form->canRegister() && !$this->isRegisteringLater($request, $form)) {
|
|
||||||
throw ValidationException::withMessages(['event' => 'Anmeldung zzt nicht möglich.']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$participant = $this->handle($form, $request->validated());
|
$participant = $this->handle($form, $request->validated());
|
||||||
|
|
||||||
if ($this->isRegisteringLater($request, $form)) {
|
|
||||||
Cache::forget('later_'.request('id'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return response()->json($participant);
|
return response()->json($participant);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isRegisteringLater(ActionRequest $request, Form $form): 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',
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (!URL::hasValidSignature($request) || $validator->fails()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Cache::get('later_'.data_get($validator->validated(), 'id')) === $form->id;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?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),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,31 +0,0 @@
|
||||||
<?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,7 +6,6 @@ use App\Form\Fields\Field;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Spatie\LaravelData\Casts\Cast;
|
use Spatie\LaravelData\Casts\Cast;
|
||||||
use Spatie\LaravelData\Data;
|
use Spatie\LaravelData\Data;
|
||||||
use Spatie\LaravelData\Support\Creation\CreationContext;
|
|
||||||
use Spatie\LaravelData\Support\DataProperty;
|
use Spatie\LaravelData\Support\DataProperty;
|
||||||
|
|
||||||
class CollectionCast implements Cast
|
class CollectionCast implements Cast
|
||||||
|
@ -21,9 +20,10 @@ class CollectionCast implements Cast
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<int, array<string, mixed>> $value
|
* @param array<int, array<string, mixed>> $value
|
||||||
|
* @param array<string, mixed> $context
|
||||||
* @return Collection<int, Data>
|
* @return Collection<int, Data>
|
||||||
*/
|
*/
|
||||||
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): mixed
|
public function cast(DataProperty $property, mixed $value, array $context): mixed
|
||||||
{
|
{
|
||||||
return collect($value)->map(fn ($item) => $this->target::from($item));
|
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\Data\FieldCollection;
|
||||||
use App\Form\Fields\Field;
|
use App\Form\Fields\Field;
|
||||||
use Spatie\LaravelData\Casts\Cast;
|
use Spatie\LaravelData\Casts\Cast;
|
||||||
use Spatie\LaravelData\Support\Creation\CreationContext;
|
|
||||||
use Spatie\LaravelData\Support\DataProperty;
|
use Spatie\LaravelData\Support\DataProperty;
|
||||||
|
|
||||||
class FieldCollectionCast implements Cast
|
class FieldCollectionCast implements Cast
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param array<int, array<string, string>> $value
|
* @param array<int, array<string, mixed>> $value
|
||||||
|
* @param array<string, mixed> $context
|
||||||
* @return FieldCollection
|
* @return FieldCollection
|
||||||
*/
|
*/
|
||||||
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): mixed
|
public function cast(DataProperty $property, mixed $value, array $context): mixed
|
||||||
{
|
{
|
||||||
return new FieldCollection(collect($value)->map(fn ($value) => Field::classFromType($value['type'])::from($value))->all());
|
return new FieldCollection(collect($value)->map(fn ($value) => Field::classFromType($value['type'])::from($value))->all());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Form\Contracts;
|
|
||||||
|
|
||||||
interface Filterable
|
|
||||||
{
|
|
||||||
/** @param mixed $value */
|
|
||||||
public function filter($value): string;
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Form\Data;
|
|
||||||
|
|
||||||
use App\Fileshare\Data\FileshareResourceData;
|
|
||||||
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)]
|
|
||||||
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,7 +2,6 @@
|
||||||
|
|
||||||
namespace App\Form\Data;
|
namespace App\Form\Data;
|
||||||
|
|
||||||
use App\Form\Contracts\Filterable;
|
|
||||||
use App\Form\Enums\SpecialType;
|
use App\Form\Enums\SpecialType;
|
||||||
use App\Form\Fields\Field;
|
use App\Form\Fields\Field;
|
||||||
use App\Form\Fields\NamiField;
|
use App\Form\Fields\NamiField;
|
||||||
|
@ -36,11 +35,6 @@ class FieldCollection extends Collection
|
||||||
return $this->filter(fn ($field) => !is_a($field, NamiField::class));
|
return $this->filter(fn ($field) => !is_a($field, NamiField::class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasNamiField(): bool
|
|
||||||
{
|
|
||||||
return $this->first(fn ($field) => is_a($field, NamiField::class)) !== null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return stdClass
|
* @return stdClass
|
||||||
*/
|
*/
|
||||||
|
@ -114,36 +108,8 @@ class FieldCollection extends Collection
|
||||||
return $this->map(fn ($field) => $field->presentRaw())->toArray();
|
return $this->map(fn ($field) => $field->presentRaw())->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasSpecialType(SpecialType $specialType): bool
|
private function findBySpecialType(SpecialType $specialType): ?Field
|
||||||
{
|
|
||||||
return $this->findBySpecialType($specialType) !== null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findBySpecialType(SpecialType $specialType): ?Field
|
|
||||||
{
|
{
|
||||||
return $this->first(fn ($field) => $field->specialType === $specialType);
|
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,7 +8,6 @@ use Illuminate\Support\Collection;
|
||||||
use Spatie\LaravelData\Data;
|
use Spatie\LaravelData\Data;
|
||||||
use Spatie\LaravelData\Attributes\WithCast;
|
use Spatie\LaravelData\Attributes\WithCast;
|
||||||
use Spatie\LaravelData\Attributes\WithTransformer;
|
use Spatie\LaravelData\Attributes\WithTransformer;
|
||||||
use Spatie\LaravelData\Support\EloquentCasts\DataEloquentCast;
|
|
||||||
|
|
||||||
class FormConfigData extends Data
|
class FormConfigData extends Data
|
||||||
{
|
{
|
||||||
|
@ -30,13 +29,4 @@ class FormConfigData extends Data
|
||||||
new FieldCollection([])
|
new FieldCollection([])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<int, mixed> $arguments
|
|
||||||
* @return DataEloquentCast<self>
|
|
||||||
*/
|
|
||||||
public static function castUsing(array $arguments): DataEloquentCast
|
|
||||||
{
|
|
||||||
return new DataEloquentCast(static::class, $arguments);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,7 @@ class SectionData extends Data
|
||||||
public string $name,
|
public string $name,
|
||||||
#[WithCast(FieldCollectionCast::class)]
|
#[WithCast(FieldCollectionCast::class)]
|
||||||
#[WithTransformer(FieldCollectionTransformer::class)]
|
#[WithTransformer(FieldCollectionTransformer::class)]
|
||||||
public FieldCollection $fields,
|
public FieldCollection $fields
|
||||||
public ?string $intro
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
namespace App\Form\Editor;
|
namespace App\Form\Editor;
|
||||||
|
|
||||||
use App\Form\Models\Participant;
|
use App\Form\Models\Participant;
|
||||||
use App\Lib\Editor\Condition;
|
|
||||||
use App\Lib\Editor\ConditionResolver;
|
use App\Lib\Editor\ConditionResolver;
|
||||||
|
|
||||||
class FormConditionResolver extends ConditionResolver
|
class FormConditionResolver extends ConditionResolver
|
||||||
|
@ -21,24 +20,24 @@ class FormConditionResolver extends ConditionResolver
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
public function filterCondition(Condition $condition): bool
|
public function filterCondition(string $mode, array $ifs): bool
|
||||||
{
|
{
|
||||||
if (!$condition->hasStatements()) {
|
if (count($ifs) === 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($condition->ifs as $if) {
|
foreach ($ifs as $if) {
|
||||||
$field = $this->participant->getFields()->findByKey($if->field);
|
$field = $this->participant->getFields()->findByKey($if['field']);
|
||||||
$matches = $field->matches($if->comparator, $if->value);
|
$matches = $field->matches($if['comparator'], $if['value']);
|
||||||
if ($matches && $condition->isAny()) {
|
if ($matches && $mode === 'any') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!$matches && $condition->isAll()) {
|
if (!$matches && $mode === 'all') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($condition->isAny()) {
|
if ($mode === 'any') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace App\Form\Enums;
|
namespace App\Form\Enums;
|
||||||
|
|
||||||
use App\Form\Models\Form;
|
|
||||||
use App\Group\Enums\Level;
|
use App\Group\Enums\Level;
|
||||||
use App\Member\Member;
|
use App\Member\Member;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
@ -19,10 +18,6 @@ enum NamiType: string
|
||||||
case ADDRESS = 'Adresse';
|
case ADDRESS = 'Adresse';
|
||||||
case ZIP = 'PLZ';
|
case ZIP = 'PLZ';
|
||||||
case LOCATION = 'Ort';
|
case LOCATION = 'Ort';
|
||||||
case GENDER = 'Geschlecht';
|
|
||||||
case MOBILEPHONE = 'Handynummer';
|
|
||||||
case AGE = 'Alter (zum Zeitpunkt der Anmeldung)';
|
|
||||||
case AGEEVENT = 'Alter (zum Zeitpunkt der Veranstaltung)';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<int, array{name: string, id: string}>
|
* @return array<int, array{name: string, id: string}>
|
||||||
|
@ -34,7 +29,7 @@ enum NamiType: string
|
||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMemberAttribute(Member $member, Form $form): ?string
|
public function getMemberAttribute(Member $member): ?string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
static::FIRSTNAME => $member->firstname,
|
static::FIRSTNAME => $member->firstname,
|
||||||
|
@ -47,10 +42,6 @@ enum NamiType: string
|
||||||
static::ZIP => $member->zip,
|
static::ZIP => $member->zip,
|
||||||
static::LOCATION => $member->location,
|
static::LOCATION => $member->location,
|
||||||
static::NICKNAME => $member->nickname,
|
static::NICKNAME => $member->nickname,
|
||||||
static::GENDER => $member->gender?->name,
|
|
||||||
static::AGE => intVal($member->birthday->diffInYears(now())),
|
|
||||||
static::AGEEVENT => $member->birthday->diffInYears($form->from),
|
|
||||||
static::MOBILEPHONE => $member->mobile_phone,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +55,7 @@ enum NamiType: string
|
||||||
static::FIRSTNAME => $query->where('firstname', $value),
|
static::FIRSTNAME => $query->where('firstname', $value),
|
||||||
static::LASTNAME => $query->where('lastname', $value),
|
static::LASTNAME => $query->where('lastname', $value),
|
||||||
static::BIRTHDAY => $query->where('birthday', $value),
|
static::BIRTHDAY => $query->where('birthday', $value),
|
||||||
|
static::EMAIL => $query->where('email', $value),
|
||||||
default => $query,
|
default => $query,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,6 @@ enum SpecialType: string
|
||||||
case FIRSTNAME = 'Vorname';
|
case FIRSTNAME = 'Vorname';
|
||||||
case LASTNAME = 'Nachname';
|
case LASTNAME = 'Nachname';
|
||||||
case EMAIL = 'E-Mail-Adresse';
|
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}>
|
* @return array<int, array{name: string, id: string}>
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace App\Form\Fields;
|
namespace App\Form\Fields;
|
||||||
|
|
||||||
use App\Form\Contracts\Filterable;
|
|
||||||
use App\Form\Matchers\BooleanMatcher;
|
use App\Form\Matchers\BooleanMatcher;
|
||||||
use App\Form\Matchers\Matcher;
|
use App\Form\Matchers\Matcher;
|
||||||
use App\Form\Models\Form;
|
use App\Form\Models\Form;
|
||||||
|
@ -10,8 +9,9 @@ use App\Form\Models\Participant;
|
||||||
use App\Form\Presenters\BooleanPresenter;
|
use App\Form\Presenters\BooleanPresenter;
|
||||||
use App\Form\Presenters\Presenter;
|
use App\Form\Presenters\Presenter;
|
||||||
use Faker\Generator;
|
use Faker\Generator;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class CheckboxField extends Field implements Filterable
|
class CheckboxField extends Field
|
||||||
{
|
{
|
||||||
public bool $required;
|
public bool $required;
|
||||||
public string $description;
|
public string $description;
|
||||||
|
@ -86,11 +86,4 @@ class CheckboxField extends Field implements Filterable
|
||||||
{
|
{
|
||||||
return app(BooleanMatcher::class);
|
return app(BooleanMatcher::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function filter($value): string
|
|
||||||
{
|
|
||||||
$asString = $value ? 'true' : 'false';
|
|
||||||
|
|
||||||
return "{$this->key} = $asString";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,6 @@ class CheckboxesField extends Field
|
||||||
{
|
{
|
||||||
/** @var array<int, string> */
|
/** @var array<int, string> */
|
||||||
public array $options;
|
public array $options;
|
||||||
public ?int $min;
|
|
||||||
public ?int $max;
|
|
||||||
|
|
||||||
public static function name(): string
|
public static function name(): string
|
||||||
{
|
{
|
||||||
|
@ -25,8 +23,6 @@ class CheckboxesField extends Field
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
['key' => 'options', 'default' => [], 'rules' => ['options' => 'array', 'options.*' => 'required|string'], 'label' => 'Optionen'],
|
['key' => 'options', 'default' => [], 'rules' => ['options' => 'array', 'options.*' => 'required|string'], 'label' => 'Optionen'],
|
||||||
['key' => 'min', 'default' => null, 'rules' => ['min' => 'present'], 'label' => 'minimale Anzahl'],
|
|
||||||
['key' => 'max', 'default' => null, 'rules' => ['max' => 'present'], 'label' => 'maximale Anzahl'],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,8 +35,6 @@ class CheckboxesField extends Field
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'options' => $faker->words(4),
|
'options' => $faker->words(4),
|
||||||
'min' => null,
|
|
||||||
'max' => null,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,18 +43,8 @@ class CheckboxesField extends Field
|
||||||
*/
|
*/
|
||||||
public function getRegistrationRules(Form $form): array
|
public function getRegistrationRules(Form $form): array
|
||||||
{
|
{
|
||||||
$globalRules = ['array'];
|
|
||||||
|
|
||||||
if ($this->min > 0) {
|
|
||||||
$globalRules[] = 'min:' . $this->min;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->max > 0) {
|
|
||||||
$globalRules[] = 'max:' . $this->max;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
$this->key => $globalRules,
|
$this->key => 'array',
|
||||||
$this->key . '.*' => ['string', Rule::in($this->options)],
|
$this->key . '.*' => ['string', Rule::in($this->options)],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace App\Form\Fields;
|
namespace App\Form\Fields;
|
||||||
|
|
||||||
use App\Form\Contracts\Filterable;
|
|
||||||
use App\Form\Matchers\Matcher;
|
use App\Form\Matchers\Matcher;
|
||||||
use App\Form\Matchers\SingleValueMatcher;
|
use App\Form\Matchers\SingleValueMatcher;
|
||||||
use App\Form\Models\Form;
|
use App\Form\Models\Form;
|
||||||
|
@ -10,7 +9,7 @@ use App\Form\Models\Participant;
|
||||||
use Faker\Generator;
|
use Faker\Generator;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class DropdownField extends Field implements Filterable
|
class DropdownField extends Field
|
||||||
{
|
{
|
||||||
public bool $required;
|
public bool $required;
|
||||||
/** @var array<int, string> */
|
/** @var array<int, string> */
|
||||||
|
@ -88,14 +87,4 @@ class DropdownField extends Field implements Filterable
|
||||||
{
|
{
|
||||||
return app(SingleValueMatcher::class);
|
return app(SingleValueMatcher::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @inheritdoc */
|
|
||||||
public function filter($value): string
|
|
||||||
{
|
|
||||||
if (is_null($value)) {
|
|
||||||
return "{$this->key} IS NULL";
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->key . ' = \'' . $value . '\'';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ use App\Form\Models\Form;
|
||||||
use App\Form\Models\Participant;
|
use App\Form\Models\Participant;
|
||||||
use App\Form\Presenters\DefaultPresenter;
|
use App\Form\Presenters\DefaultPresenter;
|
||||||
use App\Form\Presenters\Presenter;
|
use App\Form\Presenters\Presenter;
|
||||||
use App\Lib\Editor\Comparator;
|
|
||||||
use Faker\Generator;
|
use Faker\Generator;
|
||||||
use Spatie\LaravelData\Data;
|
use Spatie\LaravelData\Data;
|
||||||
use Spatie\LaravelData\Attributes\MapInputName;
|
use Spatie\LaravelData\Attributes\MapInputName;
|
||||||
|
@ -80,9 +79,6 @@ abstract class Field extends Data
|
||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return class-string<Field>
|
|
||||||
*/
|
|
||||||
public static function classFromType(string $type): ?string
|
public static function classFromType(string $type): ?string
|
||||||
{
|
{
|
||||||
/** @var class-string<Field> */
|
/** @var class-string<Field> */
|
||||||
|
@ -105,7 +101,10 @@ abstract class Field extends Data
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function presentRaw(): string
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function presentRaw()
|
||||||
{
|
{
|
||||||
return $this->getPresenter()->present($this->value);
|
return $this->getPresenter()->present($this->value);
|
||||||
}
|
}
|
||||||
|
@ -171,7 +170,7 @@ abstract class Field extends Data
|
||||||
return $this->key . '_display';
|
return $this->key . '_display';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function matches(Comparator $comparator, mixed $value): bool
|
public function matches(string $comparator, mixed $value): bool
|
||||||
{
|
{
|
||||||
return $this->getMatcher()->setValue($this->value)->matches($comparator, $value);
|
return $this->getMatcher()->setValue($this->value)->matches($comparator, $value);
|
||||||
}
|
}
|
||||||
|
@ -180,10 +179,4 @@ abstract class Field extends Data
|
||||||
{
|
{
|
||||||
return app(SingleValueMatcher::class);
|
return app(SingleValueMatcher::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param mixed $value */
|
|
||||||
public function filter($value): string
|
|
||||||
{
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ class GroupField extends Field
|
||||||
$rules[] = Rule::in(Group::find($this->parentGroup)->children()->pluck('id')->push(-1));
|
$rules[] = Rule::in(Group::find($this->parentGroup)->children()->pluck('id')->push(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->parentField && request()->input($this->parentField) && request()->input($this->parentField) !== -1) {
|
if ($this->parentField && request()->input($this->parentField)) {
|
||||||
$rules[] = Rule::in(Group::find(request()->input($this->parentField))->children()->pluck('id')->push(-1));
|
$rules[] = Rule::in(Group::find(request()->input($this->parentField))->children()->pluck('id')->push(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,18 +42,19 @@ class NamiField extends Field
|
||||||
public function getRegistrationRules(Form $form): array
|
public function getRegistrationRules(Form $form): array
|
||||||
{
|
{
|
||||||
$rules = [$this->key => 'present|array'];
|
$rules = [$this->key => 'present|array'];
|
||||||
$inputMembers = request($this->key);
|
|
||||||
|
|
||||||
foreach ($form->getFields()->noNamiField()->forMembers() as $field) {
|
$c = $form->getFields()->forMembers()->noNamiType()->noNamiField()
|
||||||
foreach ($field->getRegistrationRules($form) as $ruleKey => $rule) {
|
->map(fn ($field) => $field->getRegistrationRules($form))
|
||||||
foreach ($inputMembers as $memberIndex => $inputMember) {
|
->toArray();
|
||||||
$rules[$this->key . '.' . $memberIndex . '.' . $ruleKey] = !$inputMember['id'] || $field->namiType === null ? $rule : '';
|
|
||||||
}
|
foreach ($c as $field) {
|
||||||
|
foreach ($field as $ruleKey => $rule) {
|
||||||
|
$rules[$this->key . '.*.' . $ruleKey] = $rule;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
$this->key . '.*.id' => ['nullable', 'numeric', 'exists:members,mitgliedsnr'],
|
$this->key . '.*.id' => ['required', 'numeric', 'exists:members,mitgliedsnr'],
|
||||||
...$rules,
|
...$rules,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -70,9 +71,12 @@ class NamiField extends Field
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($form->getFields()->noNamiField()->forMembers() as $field) {
|
$c = $form->getFields()->noNamiField()->forMembers();
|
||||||
|
|
||||||
|
foreach ($c as $field) {
|
||||||
foreach ($field->getRegistrationRules($form) as $ruleKey => $rule) {
|
foreach ($field->getRegistrationRules($form) as $ruleKey => $rule) {
|
||||||
foreach ($inputMembers as $memberIndex => $inputMember) {
|
foreach ($inputMembers as $memberIndex => $inputMember) {
|
||||||
|
|
||||||
$message = $field->name . ' für ein Mitglied';
|
$message = $field->name . ' für ein Mitglied';
|
||||||
$rules = array_merge(
|
$rules = array_merge(
|
||||||
$rules,
|
$rules,
|
||||||
|
@ -107,16 +111,16 @@ class NamiField extends Field
|
||||||
public function afterRegistration(Form $form, Participant $participant, array $input): void
|
public function afterRegistration(Form $form, Participant $participant, array $input): void
|
||||||
{
|
{
|
||||||
foreach ($input[$this->key] as $memberData) {
|
foreach ($input[$this->key] as $memberData) {
|
||||||
$member = $memberData['id'] ? Member::firstWhere(['mitgliedsnr' => $memberData['id']]) : null;
|
$member = Member::firstWhere(['mitgliedsnr' => $memberData['id']]);
|
||||||
$data = [];
|
$data = [];
|
||||||
foreach (FieldCollection::fromRequest($form, $memberData) as $field) {
|
foreach (FieldCollection::fromRequest($form, $memberData) as $field) {
|
||||||
$data[$field->key] = $field->namiType === null || $member === null
|
$data[$field->key] = $field->namiType === null
|
||||||
? $field->value
|
? $field->value
|
||||||
: $field->namiType->getMemberAttribute($member, $form);
|
: $field->namiType->getMemberAttribute($member);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data[$this->key] = [];
|
$data[$this->key] = [];
|
||||||
$form->participants()->create(['data' => $data, 'member_id' => $member?->id, 'parent_id' => $participant->id]);
|
$form->participants()->create(['data' => $data, 'mitgliedsnr' => $memberData['id'], 'parent_id' => $participant->id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace App\Form\Fields;
|
namespace App\Form\Fields;
|
||||||
|
|
||||||
use App\Form\Contracts\Filterable;
|
|
||||||
use App\Form\Matchers\Matcher;
|
use App\Form\Matchers\Matcher;
|
||||||
use App\Form\Matchers\SingleValueMatcher;
|
use App\Form\Matchers\SingleValueMatcher;
|
||||||
use App\Form\Models\Form;
|
use App\Form\Models\Form;
|
||||||
|
@ -10,7 +9,7 @@ use App\Form\Models\Participant;
|
||||||
use Faker\Generator;
|
use Faker\Generator;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class RadioField extends Field implements Filterable
|
class RadioField extends Field
|
||||||
{
|
{
|
||||||
public bool $required;
|
public bool $required;
|
||||||
/** @var array<int, string> */
|
/** @var array<int, string> */
|
||||||
|
@ -88,13 +87,4 @@ class RadioField extends Field implements Filterable
|
||||||
{
|
{
|
||||||
return app(SingleValueMatcher::class);
|
return app(SingleValueMatcher::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function filter($value): string
|
|
||||||
{
|
|
||||||
if (is_null($value)) {
|
|
||||||
return "{$this->key} IS NULL";
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->key . ' = \'' . $value . '\'';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,13 @@
|
||||||
|
|
||||||
namespace App\Form;
|
namespace App\Form;
|
||||||
|
|
||||||
|
use App\Form\Actions\SettingIndexAction;
|
||||||
use App\Form\Actions\SettingStoreAction;
|
use App\Form\Actions\SettingStoreAction;
|
||||||
|
use App\Setting\Contracts\Indexable;
|
||||||
use App\Setting\Contracts\Storeable;
|
use App\Setting\Contracts\Storeable;
|
||||||
use App\Setting\LocalSettings;
|
use App\Setting\LocalSettings;
|
||||||
use Lorisleiva\Actions\ActionRequest;
|
|
||||||
|
|
||||||
class FormSettings extends LocalSettings implements Storeable
|
class FormSettings extends LocalSettings implements Indexable, Storeable
|
||||||
{
|
{
|
||||||
public string $registerUrl;
|
public string $registerUrl;
|
||||||
public string $clearCacheUrl;
|
public string $clearCacheUrl;
|
||||||
|
@ -17,38 +18,23 @@ class FormSettings extends LocalSettings implements Storeable
|
||||||
return 'form';
|
return 'form';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function slug(): string
|
||||||
|
{
|
||||||
|
return 'form';
|
||||||
|
}
|
||||||
|
|
||||||
public static function title(): string
|
public static function title(): string
|
||||||
{
|
{
|
||||||
return 'Formulare';
|
return 'Formulare';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static function indexAction(): string
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public function rules(): array
|
|
||||||
{
|
{
|
||||||
return [
|
return SettingIndexAction::class;
|
||||||
'registerUrl' => 'present|string',
|
|
||||||
'clearCacheUrl' => 'present|string',
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function beforeSave(ActionRequest $request): void
|
public static function storeAction(): string
|
||||||
{
|
{
|
||||||
}
|
return SettingStoreAction::class;
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
public function viewData(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'data' => [
|
|
||||||
'data' => [
|
|
||||||
'registerUrl' => $this->registerUrl,
|
|
||||||
'clearCacheUrl' => $this->clearCacheUrl,
|
|
||||||
]
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue