Compare commits
5 Commits
master
...
permission
Author | SHA1 | Date |
---|---|---|
philipp lang | 2ec7dd23eb | |
philipp lang | 4548407d55 | |
philipp lang | cbb45a0452 | |
philipp lang | 3e92a7c40a | |
philipp lang | 310f3c9727 |
|
@ -1,12 +1,11 @@
|
|||
FROM php:8.3.11-fpm as php
|
||||
FROM php:8.1.6-fpm as php
|
||||
WORKDIR /app
|
||||
RUN ls /app
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y rsync libcurl3-dev apt-utils zlib1g-dev libpng-dev libicu-dev libonig-dev unzip poppler-utils libpng-dev libjpeg-dev default-mysql-client 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 libzip-dev
|
||||
RUN apt-get install -y --no-install-recommends texlive-base texlive-latex-base texlive-pictures texlive-latex-extra texlive-lang-german texlive-plain-generic texlive-fonts-recommended texlive-fonts-extra texlive-extra-utils
|
||||
RUN docker-php-ext-install pdo_mysql curl exif intl mbstring pcntl zip
|
||||
RUN pecl install redis && docker-php-ext-enable redis
|
||||
RUN pecl install imagick && docker-php-ext-enable imagick
|
||||
RUN docker-php-ext-configure gd --with-jpeg
|
||||
RUN docker-php-ext-install gd
|
||||
RUN usermod -s /bin/bash www-data
|
||||
|
|
|
@ -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,4 +1,4 @@
|
|||
FROM composer:2.7.9 as composer
|
||||
FROM composer:2.2.7 as composer
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
RUN composer install --ignore-platform-reqs --no-dev
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM composer:2.7.9 as composer
|
||||
FROM composer:2.2.7 as composer
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
RUN composer install --ignore-platform-reqs --no-dev
|
||||
|
|
|
@ -12,7 +12,7 @@ steps:
|
|||
- git submodule update --init --recursive
|
||||
|
||||
- name: composer_dev
|
||||
image: composer:2.7.9
|
||||
image: composer:2.2.7
|
||||
commands:
|
||||
- composer install --ignore-platform-reqs --dev
|
||||
|
||||
|
@ -39,7 +39,6 @@ steps:
|
|||
- name: tests
|
||||
image: zoomyboy/adrema-base:latest
|
||||
commands:
|
||||
- touch .env
|
||||
- php artisan migrate
|
||||
- php artisan test
|
||||
- rm -f .env
|
||||
|
@ -103,7 +102,7 @@ steps:
|
|||
event: tag
|
||||
|
||||
- name: deploy
|
||||
image: zoomyboy/adrema-base:latest
|
||||
image: php:8.1.6
|
||||
environment:
|
||||
SSH_KEY:
|
||||
from_secret: deploy_private_key
|
||||
|
@ -136,7 +135,7 @@ steps:
|
|||
event: push
|
||||
|
||||
- name: composer_no_dev
|
||||
image: composer:2.7.9
|
||||
image: composer:2.2.7
|
||||
commands:
|
||||
- composer install --ignore-platform-reqs --no-dev
|
||||
|
||||
|
|
|
@ -40,4 +40,3 @@ Homestead.json
|
|||
/public/sprite.svg
|
||||
/.php-cs-fixer.cache
|
||||
/groups.sql
|
||||
/.phpunit.cache
|
||||
|
|
37
CHANGELOG.md
37
CHANGELOG.md
|
@ -1,42 +1,5 @@
|
|||
# Letzte Änderungen
|
||||
|
||||
### 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
|
||||
|
|
|
@ -50,7 +50,6 @@ class InsertMemberAction
|
|||
'nationality_id' => Nationality::where('nami_id', $member->nationalityId)->firstOrFail()->id,
|
||||
'mitgliedsnr' => $member->memberId,
|
||||
'version' => $member->version,
|
||||
'keepdata' => $member->keepdata,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,14 +4,12 @@ namespace App;
|
|||
|
||||
use App\Nami\HasNamiField;
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Database\Factories\ActivityFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Activity extends Model
|
||||
{
|
||||
/** @use HasFactory<ActivityFactory> */
|
||||
use HasFactory;
|
||||
use HasNamiField;
|
||||
use Sluggable;
|
||||
|
|
|
@ -2,13 +2,11 @@
|
|||
|
||||
namespace App;
|
||||
|
||||
use Database\Factories\ConfessionFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Confession extends Model
|
||||
{
|
||||
/** @use HasFactory<ConfessionFactory> */
|
||||
use HasFactory;
|
||||
|
||||
public $fillable = ['name', 'nami_id', 'is_null'];
|
||||
|
|
|
@ -8,7 +8,6 @@ use App\Contribution\Documents\RdpNrwDocument;
|
|||
use App\Contribution\Documents\CityRemscheidDocument;
|
||||
use App\Contribution\Documents\CitySolingenDocument;
|
||||
use App\Contribution\Documents\CityFrankfurtMainDocument;
|
||||
use App\Contribution\Documents\WuppertalDocument;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
|
@ -23,7 +22,6 @@ class ContributionFactory
|
|||
CityRemscheidDocument::class,
|
||||
CityFrankfurtMainDocument::class,
|
||||
BdkjHesse::class,
|
||||
WuppertalDocument::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -32,7 +30,7 @@ class ContributionFactory
|
|||
public function compilerSelect(): Collection
|
||||
{
|
||||
return collect($this->documents)->map(fn ($document) => [
|
||||
'title' => $document::buttonName(),
|
||||
'title' => $document::getName(),
|
||||
'class' => $document,
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class MemberData extends Data
|
|||
*/
|
||||
public static function fromModels(array $ids): Collection
|
||||
{
|
||||
return Member::whereIn('id', $ids)->orderByRaw('lastname, firstname')->get()->map(fn ($member) => self::factory()->withoutMagicalCreation()->from([
|
||||
return Member::whereIn('id', $ids)->orderByRaw('lastname, firstname')->get()->map(fn ($member) => self::withoutMagicalCreationFrom([
|
||||
...$member->toArray(),
|
||||
'birthday' => $member->birthday->toAtomString(),
|
||||
'isLeader' => $member->isLeader(),
|
||||
|
@ -44,7 +44,7 @@ class MemberData extends Data
|
|||
*/
|
||||
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,
|
||||
'birthday' => Carbon::parse($member['birthday'])->toAtomString(),
|
||||
'gender' => Gender::fromString($member['gender']),
|
||||
|
@ -54,41 +54,31 @@ class MemberData extends Data
|
|||
|
||||
public function fullname(): string
|
||||
{
|
||||
return $this->firstname . ' ' . $this->lastname;
|
||||
return $this->firstname.' '.$this->lastname;
|
||||
}
|
||||
|
||||
public function separatedName(): string
|
||||
{
|
||||
return $this->lastname . ', ' . $this->firstname;
|
||||
return $this->lastname.', '.$this->firstname;
|
||||
}
|
||||
|
||||
public function fullAddress(): string
|
||||
{
|
||||
return $this->address . ', ' . $this->zip . ' ' . $this->location;
|
||||
return $this->address.', '.$this->zip.' '.$this->location;
|
||||
}
|
||||
|
||||
public function city(): string
|
||||
{
|
||||
return $this->zip . ' ' . $this->location;
|
||||
return $this->zip.' '.$this->location;
|
||||
}
|
||||
|
||||
public function age(): int
|
||||
public function age(): string
|
||||
{
|
||||
return intval($this->birthday->diffInYears(now()));
|
||||
return (string) $this->birthday->diffInYears(now()) ?: '';
|
||||
}
|
||||
|
||||
public function birthYear(): string
|
||||
{
|
||||
return (string) $this->birthday->year;
|
||||
}
|
||||
|
||||
public function birthdayHuman(): string
|
||||
{
|
||||
return $this->birthday->format('d.m.Y');
|
||||
}
|
||||
|
||||
public function genderLetter(): string
|
||||
{
|
||||
return $this->gender->short;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,16 +3,15 @@
|
|||
namespace App\Contribution\Documents;
|
||||
|
||||
use App\Contribution\Data\MemberData;
|
||||
use App\Contribution\Traits\HasPdfBackground;
|
||||
use App\Country;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
use Zoomyboy\Tex\Engine;
|
||||
use Zoomyboy\Tex\Template;
|
||||
|
||||
class BdkjHesse extends ContributionDocument
|
||||
{
|
||||
|
||||
use HasPdfBackground;
|
||||
|
||||
/**
|
||||
* @param Collection<int, Collection<int, MemberData>> $members
|
||||
*/
|
||||
|
@ -26,7 +25,6 @@ class BdkjHesse extends ContributionDocument
|
|||
public ?string $filename = '',
|
||||
public string $type = 'F',
|
||||
) {
|
||||
$this->setEventName($eventName);
|
||||
}
|
||||
|
||||
public function dateFrom(): string
|
||||
|
@ -76,7 +74,7 @@ class BdkjHesse extends ContributionDocument
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,9 +114,36 @@ class BdkjHesse extends ContributionDocument
|
|||
return $member->birthYear();
|
||||
}
|
||||
|
||||
public function basename(): string
|
||||
{
|
||||
return 'zuschuesse-bdkj-hessen' . Str::slug($this->eventName);
|
||||
}
|
||||
|
||||
public function view(): string
|
||||
{
|
||||
return 'tex.contribution.bdkj-hesse';
|
||||
}
|
||||
|
||||
public function template(): Template
|
||||
{
|
||||
return Template::make('tex.templates.contribution');
|
||||
}
|
||||
|
||||
public function setFilename(string $filename): static
|
||||
{
|
||||
$this->filename = $filename;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEngine(): Engine
|
||||
{
|
||||
return Engine::PDFLATEX;
|
||||
}
|
||||
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'BDKJ Hessen';
|
||||
return 'Für BDKJ Hessen erstellen';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -131,6 +156,7 @@ class BdkjHesse extends ContributionDocument
|
|||
'dateUntil' => 'required|string|date_format:Y-m-d',
|
||||
'country' => 'required|integer|exists:countries,id',
|
||||
'zipLocation' => 'required|string',
|
||||
'eventName' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,17 +3,16 @@
|
|||
namespace App\Contribution\Documents;
|
||||
|
||||
use App\Contribution\Data\MemberData;
|
||||
use App\Contribution\Traits\FormatsDates;
|
||||
use App\Contribution\Traits\HasPdfBackground;
|
||||
use App\Country;
|
||||
use App\Invoice\InvoiceSettings;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
use Zoomyboy\Tex\Engine;
|
||||
use Zoomyboy\Tex\Template;
|
||||
|
||||
class CityFrankfurtMainDocument extends ContributionDocument
|
||||
{
|
||||
use HasPdfBackground;
|
||||
use FormatsDates;
|
||||
|
||||
public string $fromName;
|
||||
|
||||
/**
|
||||
|
@ -29,7 +28,6 @@ class CityFrankfurtMainDocument extends ContributionDocument
|
|||
public ?string $filename = '',
|
||||
public string $type = 'F',
|
||||
) {
|
||||
$this->setEventName($eventName);
|
||||
$this->fromName = app(InvoiceSettings::class)->from_long;
|
||||
}
|
||||
|
||||
|
@ -63,6 +61,17 @@ class CityFrankfurtMainDocument extends ContributionDocument
|
|||
);
|
||||
}
|
||||
|
||||
public function dateFromHuman(): string
|
||||
{
|
||||
return Carbon::parse($this->dateFrom)->format('d.m.Y');
|
||||
}
|
||||
|
||||
public function dateUntilHuman(): string
|
||||
{
|
||||
return Carbon::parse($this->dateUntil)->format('d.m.Y');
|
||||
}
|
||||
|
||||
|
||||
public function countryName(): string
|
||||
{
|
||||
return $this->country->name;
|
||||
|
@ -73,9 +82,56 @@ class CityFrankfurtMainDocument extends ContributionDocument
|
|||
return count($this->members);
|
||||
}
|
||||
|
||||
public function memberShort(MemberData $member): string
|
||||
{
|
||||
return $member->isLeader ? 'L' : '';
|
||||
}
|
||||
|
||||
public function memberName(MemberData $member): string
|
||||
{
|
||||
return $member->separatedName();
|
||||
}
|
||||
|
||||
public function memberAddress(MemberData $member): string
|
||||
{
|
||||
return $member->fullAddress();
|
||||
}
|
||||
|
||||
public function memberAge(MemberData $member): string
|
||||
{
|
||||
return $member->age();
|
||||
}
|
||||
|
||||
public function basename(): string
|
||||
{
|
||||
return 'zuschuesse-frankfurt-' . Str::slug($this->eventName);
|
||||
}
|
||||
|
||||
public function view(): string
|
||||
{
|
||||
return 'tex.contribution.city-frankfurt-main';
|
||||
}
|
||||
|
||||
public function template(): Template
|
||||
{
|
||||
return Template::make('tex.templates.contribution');
|
||||
}
|
||||
|
||||
public function setFilename(string $filename): static
|
||||
{
|
||||
$this->filename = $filename;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEngine(): Engine
|
||||
{
|
||||
return Engine::PDFLATEX;
|
||||
}
|
||||
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'Frankfurt';
|
||||
return 'Für Frankfurt erstellen';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,6 +144,7 @@ class CityFrankfurtMainDocument extends ContributionDocument
|
|||
'dateUntil' => 'required|string|date_format:Y-m-d',
|
||||
'country' => 'required|integer|exists:countries,id',
|
||||
'zipLocation' => 'required|string',
|
||||
'eventName' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,17 +3,15 @@
|
|||
namespace App\Contribution\Documents;
|
||||
|
||||
use App\Contribution\Data\MemberData;
|
||||
use App\Contribution\Traits\FormatsDates;
|
||||
use App\Contribution\Traits\HasPdfBackground;
|
||||
use App\Country;
|
||||
use App\Member\Member;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Zoomyboy\Tex\Engine;
|
||||
use Zoomyboy\Tex\Template;
|
||||
|
||||
class CityRemscheidDocument extends ContributionDocument
|
||||
{
|
||||
use HasPdfBackground;
|
||||
use FormatsDates;
|
||||
|
||||
/**
|
||||
* @param Collection<int, Collection<int, Member>> $leaders
|
||||
* @param Collection<int, Collection<int, Member>> $children
|
||||
|
@ -27,9 +25,17 @@ class CityRemscheidDocument extends ContributionDocument
|
|||
public Collection $children,
|
||||
public ?string $filename = '',
|
||||
public string $type = 'F',
|
||||
public string $eventName = '',
|
||||
) {
|
||||
$this->setEventName($eventName);
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,7 +52,6 @@ class CityRemscheidDocument extends ContributionDocument
|
|||
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||
leaders: $leaders->values()->toBase()->chunk(6),
|
||||
children: $children->values()->toBase()->chunk(20),
|
||||
eventName: $request['eventName'],
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -65,13 +70,39 @@ class CityRemscheidDocument extends ContributionDocument
|
|||
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||
leaders: $leaders->values()->toBase()->chunk(6),
|
||||
children: $children->values()->toBase()->chunk(20),
|
||||
eventName: $request['eventName'],
|
||||
);
|
||||
}
|
||||
|
||||
public function basename(): string
|
||||
{
|
||||
return 'zuschuesse-remscheid';
|
||||
}
|
||||
|
||||
public function view(): string
|
||||
{
|
||||
return 'tex.contribution.city-remscheid';
|
||||
}
|
||||
|
||||
public function template(): Template
|
||||
{
|
||||
return Template::make('tex.templates.contribution');
|
||||
}
|
||||
|
||||
public function setFilename(string $filename): static
|
||||
{
|
||||
$this->filename = $filename;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEngine(): Engine
|
||||
{
|
||||
return Engine::PDFLATEX;
|
||||
}
|
||||
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'Remscheid';
|
||||
return 'Für Remscheid erstellen';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,7 +6,9 @@ use App\Contribution\Data\MemberData;
|
|||
use App\Invoice\InvoiceSettings;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
use Zoomyboy\Tex\Engine;
|
||||
use Zoomyboy\Tex\Template;
|
||||
|
||||
class CitySolingenDocument extends ContributionDocument
|
||||
{
|
||||
|
@ -23,7 +25,6 @@ class CitySolingenDocument extends ContributionDocument
|
|||
public string $eventName,
|
||||
public string $type = 'F',
|
||||
) {
|
||||
$this->setEventName($eventName);
|
||||
$this->fromName = app(InvoiceSettings::class)->from_long;
|
||||
}
|
||||
|
||||
|
@ -73,6 +74,11 @@ class CitySolingenDocument extends ContributionDocument
|
|||
return Carbon::parse($this->dateUntil)->format('d.m.Y');
|
||||
}
|
||||
|
||||
public function template(): Template
|
||||
{
|
||||
return Template::make('tex.templates.contribution');
|
||||
}
|
||||
|
||||
public function checkboxes(): string
|
||||
{
|
||||
$output = '';
|
||||
|
@ -88,6 +94,16 @@ class CitySolingenDocument extends ContributionDocument
|
|||
return $firstRow . "\n" . $secondRow;
|
||||
}
|
||||
|
||||
public function basename(): string
|
||||
{
|
||||
return 'zuschuesse-solingen-' . Str::slug($this->eventName);
|
||||
}
|
||||
|
||||
public function view(): string
|
||||
{
|
||||
return 'tex.contribution.city-solingen';
|
||||
}
|
||||
|
||||
public function getEngine(): Engine
|
||||
{
|
||||
return Engine::PDFLATEX;
|
||||
|
@ -95,7 +111,7 @@ class CitySolingenDocument extends ContributionDocument
|
|||
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'Stadt Solingen';
|
||||
return 'Für Stadt Solingen erstellen';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -107,6 +123,7 @@ class CitySolingenDocument extends ContributionDocument
|
|||
'dateFrom' => 'required|string|date_format:Y-m-d',
|
||||
'dateUntil' => 'required|string|date_format:Y-m-d',
|
||||
'zipLocation' => 'required|string',
|
||||
'eventName' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,12 +3,9 @@
|
|||
namespace App\Contribution\Documents;
|
||||
|
||||
use Zoomyboy\Tex\Document;
|
||||
use Zoomyboy\Tex\Template;
|
||||
|
||||
abstract class ContributionDocument extends Document
|
||||
{
|
||||
private string $eventName;
|
||||
|
||||
abstract public static function getName(): string;
|
||||
|
||||
/**
|
||||
|
@ -32,34 +29,8 @@ abstract class ContributionDocument extends Document
|
|||
public static function globalRules(): array
|
||||
{
|
||||
return [
|
||||
'eventName' => 'required|string',
|
||||
'members' => 'present|array|min:1',
|
||||
'members.*' => 'integer|exists:members,id',
|
||||
];
|
||||
}
|
||||
|
||||
public static function buttonName(): string
|
||||
{
|
||||
return 'Für ' . static::getName() . ' erstellen';;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,16 +3,14 @@
|
|||
namespace App\Contribution\Documents;
|
||||
|
||||
use App\Contribution\Data\MemberData;
|
||||
use App\Contribution\Traits\FormatsDates;
|
||||
use App\Contribution\Traits\HasPdfBackground;
|
||||
use App\Country;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Zoomyboy\Tex\Engine;
|
||||
use Zoomyboy\Tex\Template;
|
||||
|
||||
class RdpNrwDocument extends ContributionDocument
|
||||
{
|
||||
use HasPdfBackground;
|
||||
use FormatsDates;
|
||||
|
||||
/**
|
||||
* @param Collection<int, Collection<int, MemberData>> $members
|
||||
*/
|
||||
|
@ -24,9 +22,14 @@ class RdpNrwDocument extends ContributionDocument
|
|||
public Collection $members,
|
||||
public ?string $filename = '',
|
||||
public string $type = 'F',
|
||||
public string $eventName = '',
|
||||
) {
|
||||
$this->setEventName($eventName);
|
||||
}
|
||||
|
||||
public function dateRange(): string
|
||||
{
|
||||
return Carbon::parse($this->dateFrom)->format('d.m.Y')
|
||||
. ' - '
|
||||
. Carbon::parse($this->dateUntil)->format('d.m.Y');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,7 +43,6 @@ class RdpNrwDocument extends ContributionDocument
|
|||
zipLocation: $request['zipLocation'],
|
||||
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||
members: MemberData::fromModels($request['members'])->chunk(17),
|
||||
eventName: $request['eventName'],
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -55,7 +57,6 @@ class RdpNrwDocument extends ContributionDocument
|
|||
zipLocation: $request['zipLocation'],
|
||||
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||
members: MemberData::fromApi($request['member_data'])->chunk(17),
|
||||
eventName: $request['eventName'],
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -64,9 +65,65 @@ class RdpNrwDocument extends ContributionDocument
|
|||
return $this->country->name;
|
||||
}
|
||||
|
||||
public function memberShort(MemberData $member): string
|
||||
{
|
||||
return $member->isLeader ? 'L' : '';
|
||||
}
|
||||
|
||||
public function memberName(MemberData $member): string
|
||||
{
|
||||
return $member->separatedName();
|
||||
}
|
||||
|
||||
public function memberAddress(MemberData $member): string
|
||||
{
|
||||
return $member->fullAddress();
|
||||
}
|
||||
|
||||
public function memberGender(MemberData $member): string
|
||||
{
|
||||
if (!$member->gender) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return strtolower(substr($member->gender->name, 0, 1));
|
||||
}
|
||||
|
||||
public function memberAge(MemberData $member): string
|
||||
{
|
||||
return $member->age();
|
||||
}
|
||||
|
||||
public function basename(): string
|
||||
{
|
||||
return 'zuschuesse-rdp-nrw';
|
||||
}
|
||||
|
||||
public function view(): string
|
||||
{
|
||||
return 'tex.contribution.rdp-nrw';
|
||||
}
|
||||
|
||||
public function template(): Template
|
||||
{
|
||||
return Template::make('tex.templates.contribution');
|
||||
}
|
||||
|
||||
public function setFilename(string $filename): static
|
||||
{
|
||||
$this->filename = $filename;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEngine(): Engine
|
||||
{
|
||||
return Engine::PDFLATEX;
|
||||
}
|
||||
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'RdP NRW';
|
||||
return 'Für RdP NRW erstellen';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,6 +136,7 @@ class RdpNrwDocument extends ContributionDocument
|
|||
'dateUntil' => 'required|string|date_format:Y-m-d',
|
||||
'country' => 'required|integer|exists:countries,id',
|
||||
'zipLocation' => 'required|string',
|
||||
'eventName' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contribution\Documents;
|
||||
|
||||
use App\Contribution\Data\MemberData;
|
||||
use App\Contribution\Traits\FormatsDates;
|
||||
use App\Contribution\Traits\HasPdfBackground;
|
||||
use App\Country;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class WuppertalDocument extends ContributionDocument
|
||||
{
|
||||
|
||||
use HasPdfBackground;
|
||||
use FormatsDates;
|
||||
|
||||
/**
|
||||
* @param Collection<int, Collection<int, MemberData>> $members
|
||||
*/
|
||||
public function __construct(
|
||||
public string $dateFrom,
|
||||
public string $dateUntil,
|
||||
public string $zipLocation,
|
||||
public ?Country $country,
|
||||
public Collection $members,
|
||||
public ?string $filename = '',
|
||||
public string $type = 'F',
|
||||
public string $eventName = '',
|
||||
) {
|
||||
$this->setEventName($eventName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function fromRequest(array $request): self
|
||||
{
|
||||
return new self(
|
||||
dateFrom: $request['dateFrom'],
|
||||
dateUntil: $request['dateUntil'],
|
||||
zipLocation: $request['zipLocation'],
|
||||
country: Country::where('id', $request['country'])->firstOrFail(),
|
||||
members: MemberData::fromModels($request['members'])->chunk(14),
|
||||
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(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',
|
||||
];
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
use App\Nami\HasNamiField;
|
||||
use Database\Factories\CountryFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Country extends Model
|
||||
{
|
||||
/** @use HasFactory<CountryFactory> */
|
||||
use HasFactory;
|
||||
use HasNamiField;
|
||||
|
||||
|
|
|
@ -3,13 +3,11 @@
|
|||
namespace App\Course\Models;
|
||||
|
||||
use App\Nami\HasNamiField;
|
||||
use Database\Factories\Course\Models\CourseFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Course extends Model
|
||||
{
|
||||
/** @use HasFactory<CourseFactory> */
|
||||
use HasFactory;
|
||||
use HasNamiField;
|
||||
|
||||
|
|
|
@ -3,14 +3,12 @@
|
|||
namespace App\Course\Models;
|
||||
|
||||
use App\Member\Member;
|
||||
use Database\Factories\Course\Models\CourseMemberFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class CourseMember extends Model
|
||||
{
|
||||
/** @use HasFactory<CourseMemberFactory> */
|
||||
use HasFactory;
|
||||
|
||||
/** @var array<int, string> */
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
namespace App\Dashboard;
|
||||
|
||||
use Illuminate\Routing\Router;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use App\Dashboard\Actions\IndexAction as DashboardIndexAction;
|
||||
|
||||
class DashboardServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
@ -25,8 +23,5 @@ class DashboardServiceProvider extends ServiceProvider
|
|||
*/
|
||||
public function boot()
|
||||
{
|
||||
app(Router::class)->middleware(['web', 'auth:web'])->group(function ($router) {
|
||||
$router->get('/', DashboardIndexAction::class)->name('home');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class EfzPendingBlock extends Block
|
|||
})
|
||||
->whereCurrentGroup()
|
||||
->orderByRaw('lastname, firstname')
|
||||
->whereHas('memberships', fn ($builder) => $builder->isLeader()->active());
|
||||
->whereHas('memberships', fn ($builder) => $builder->isLeader());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,14 +4,12 @@ namespace App;
|
|||
|
||||
use App\Nami\HasNamiField;
|
||||
use App\Payment\Subscription;
|
||||
use Database\Factories\FeeFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Fee extends Model
|
||||
{
|
||||
/** @use HasFactory<FeeFactory> */
|
||||
use HasFactory;
|
||||
use HasNamiField;
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -17,6 +17,6 @@ class ListFilesAction
|
|||
*/
|
||||
public function handle(ActionRequest $request, Fileshare $fileshare): DataCollection
|
||||
{
|
||||
return ResourceData::collect($fileshare->type->getSubDirectories($request->input('parent')), DataCollection::class)->wrap('data');
|
||||
return ResourceData::collection($fileshare->type->getSubDirectories($request->input('parent')))->wrap('data');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,10 +21,8 @@ class FileshareSettings extends LocalSettings
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function viewData(): array
|
||||
public function data()
|
||||
{
|
||||
return [
|
||||
'data' => FileshareResource::collection(Fileshare::paginate(15))
|
||||
];
|
||||
return FileshareResource::collection(Fileshare::paginate(15));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,11 @@
|
|||
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 = [];
|
||||
|
|
|
@ -22,8 +22,8 @@ class FormUpdateMetaAction
|
|||
|
||||
return [
|
||||
'sorting' => 'array',
|
||||
'sorting.by' => 'required|string',
|
||||
'sorting.direction' => 'required|boolean',
|
||||
'sorting.0' => 'required|string',
|
||||
'sorting.1' => 'required|string|in:asc,desc',
|
||||
'active_columns' => 'array',
|
||||
'active_columns.*' => ['string', Rule::in([...$form->getFields()->pluck('key')->toArray(), 'created_at', 'prevention'])]
|
||||
];
|
||||
|
|
|
@ -6,8 +6,9 @@ use App\Form\Models\Form;
|
|||
use App\Form\Models\Participant;
|
||||
use App\Form\Resources\ParticipantResource;
|
||||
use App\Form\Scopes\ParticipantFilterScope;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||
use Laravel\Scout\Builder;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class ParticipantIndexAction
|
||||
|
@ -15,22 +16,29 @@ class ParticipantIndexAction
|
|||
use AsAction;
|
||||
|
||||
/**
|
||||
* @return Builder<Participant>
|
||||
* @return HasMany<Participant>
|
||||
*/
|
||||
protected function getQuery(Form $form, ParticipantFilterScope $filter): Builder
|
||||
protected function getQuery(Form $form, ParticipantFilterScope $filter): HasMany
|
||||
{
|
||||
return $filter->setForm($form)->getQuery()
|
||||
->query(fn ($q) => $q->withCount('children')->with('form'));
|
||||
return $form->participants()->withFilter($filter)->withCount('children')->with('form');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return LengthAwarePaginator<Participant>
|
||||
*/
|
||||
public function handle(Form $form, ParticipantFilterScope $filter): LengthAwarePaginator
|
||||
{
|
||||
return $this->getQuery($form, $filter)->paginate(15);
|
||||
}
|
||||
|
||||
public function asController(Form $form, ?int $parent = null): AnonymousResourceCollection
|
||||
{
|
||||
$filter = ParticipantFilterScope::fromRequest(request()->input('filter', ''))->parent($parent);
|
||||
$filter = ParticipantFilterScope::fromRequest(request()->input('filter'));
|
||||
|
||||
$data = match ($parent) {
|
||||
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
|
||||
null => $this->handle($form, $filter),
|
||||
-1 => $this->getQuery($form, $filter)->where('parent_id', null)->paginate(15),
|
||||
default => $this->getQuery($form, $filter)->where('parent_id', $parent)->get(),
|
||||
};
|
||||
|
||||
return ParticipantResource::collection($data)->additional(['meta' => ParticipantResource::meta($form)]);
|
||||
|
|
|
@ -17,12 +17,7 @@ class PreventionRememberAction
|
|||
|
||||
public function handle(): void
|
||||
{
|
||||
$query = Participant::whereHas(
|
||||
'form',
|
||||
fn ($form) => $form
|
||||
->where('needs_prevention', true)
|
||||
->where('from', '>=', now())
|
||||
)
|
||||
$query = Participant::whereHas('form', fn ($form) => $form->where('needs_prevention', true))
|
||||
->where(
|
||||
fn ($q) => $q
|
||||
->where('last_remembered_at', '<=', now()->subWeeks(2))
|
||||
|
|
|
@ -7,7 +7,6 @@ use App\Form\Models\Form;
|
|||
use App\Form\Models\Participant;
|
||||
use App\Member\Member;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
|
@ -20,10 +19,6 @@ class RegisterAction
|
|||
*/
|
||||
public function handle(Form $form, array $input): Participant
|
||||
{
|
||||
if (!$form->canRegister()) {
|
||||
throw ValidationException::withMessages(['event' => 'Anmeldung zzt nicht möglich.']);
|
||||
}
|
||||
|
||||
$memberQuery = FieldCollection::fromRequest($form, $input)
|
||||
->withNamiType()
|
||||
->reduce(fn ($query, $field) => $field->namiType->performQuery($query, $field->value), (new Member())->newQuery());
|
||||
|
|
|
@ -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 Spatie\LaravelData\Casts\Cast;
|
||||
use Spatie\LaravelData\Data;
|
||||
use Spatie\LaravelData\Support\Creation\CreationContext;
|
||||
use Spatie\LaravelData\Support\DataProperty;
|
||||
|
||||
class CollectionCast implements Cast
|
||||
|
@ -21,9 +20,10 @@ class CollectionCast implements Cast
|
|||
|
||||
/**
|
||||
* @param array<int, array<string, mixed>> $value
|
||||
* @param array<string, mixed> $context
|
||||
* @return Collection<int, Data>
|
||||
*/
|
||||
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): mixed
|
||||
public function cast(DataProperty $property, mixed $value, array $context): mixed
|
||||
{
|
||||
return collect($value)->map(fn ($item) => $this->target::from($item));
|
||||
}
|
||||
|
|
|
@ -5,16 +5,16 @@ namespace App\Form\Casts;
|
|||
use App\Form\Data\FieldCollection;
|
||||
use App\Form\Fields\Field;
|
||||
use Spatie\LaravelData\Casts\Cast;
|
||||
use Spatie\LaravelData\Support\Creation\CreationContext;
|
||||
use Spatie\LaravelData\Support\DataProperty;
|
||||
|
||||
class FieldCollectionCast implements Cast
|
||||
{
|
||||
/**
|
||||
* @param array<int, array<string, string>> $value
|
||||
* @param array<string, mixed> $context
|
||||
* @return FieldCollection
|
||||
*/
|
||||
public function cast(DataProperty $property, mixed $value, array $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());
|
||||
}
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Form\Contracts;
|
||||
|
||||
interface Filterable
|
||||
{
|
||||
/** @param mixed $value */
|
||||
public function filter($value): string;
|
||||
}
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Form\Data;
|
||||
|
||||
use App\Form\Contracts\Filterable;
|
||||
use App\Form\Enums\SpecialType;
|
||||
use App\Form\Fields\Field;
|
||||
use App\Form\Fields\NamiField;
|
||||
|
@ -118,27 +117,4 @@ class FieldCollection extends Collection
|
|||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ enum NamiType: string
|
|||
static::LOCATION => $member->location,
|
||||
static::NICKNAME => $member->nickname,
|
||||
static::GENDER => $member->gender?->name,
|
||||
static::AGE => intVal($member->birthday->diffInYears(now())),
|
||||
static::AGE => $member->birthday->diffInYears(now()),
|
||||
static::AGEEVENT => $member->birthday->diffInYears($form->from),
|
||||
static::MOBILEPHONE => $member->mobile_phone,
|
||||
};
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Form\Fields;
|
||||
|
||||
use App\Form\Contracts\Filterable;
|
||||
use App\Form\Matchers\BooleanMatcher;
|
||||
use App\Form\Matchers\Matcher;
|
||||
use App\Form\Models\Form;
|
||||
|
@ -10,8 +9,9 @@ use App\Form\Models\Participant;
|
|||
use App\Form\Presenters\BooleanPresenter;
|
||||
use App\Form\Presenters\Presenter;
|
||||
use Faker\Generator;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CheckboxField extends Field implements Filterable
|
||||
class CheckboxField extends Field
|
||||
{
|
||||
public bool $required;
|
||||
public string $description;
|
||||
|
@ -86,11 +86,4 @@ class CheckboxField extends Field implements Filterable
|
|||
{
|
||||
return app(BooleanMatcher::class);
|
||||
}
|
||||
|
||||
public function filter($value): string
|
||||
{
|
||||
$asString = $value ? 'true' : 'false';
|
||||
|
||||
return "{$this->key} = $asString";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Form\Fields;
|
||||
|
||||
use App\Form\Contracts\Filterable;
|
||||
use App\Form\Matchers\Matcher;
|
||||
use App\Form\Matchers\SingleValueMatcher;
|
||||
use App\Form\Models\Form;
|
||||
|
@ -10,7 +9,7 @@ use App\Form\Models\Participant;
|
|||
use Faker\Generator;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class DropdownField extends Field implements Filterable
|
||||
class DropdownField extends Field
|
||||
{
|
||||
public bool $required;
|
||||
/** @var array<int, string> */
|
||||
|
@ -88,14 +87,4 @@ class DropdownField extends Field implements Filterable
|
|||
{
|
||||
return app(SingleValueMatcher::class);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function filter($value): string
|
||||
{
|
||||
if (is_null($value)) {
|
||||
return "{$this->key} IS NULL";
|
||||
}
|
||||
|
||||
return $this->key . ' = \'' . $value . '\'';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,10 +180,4 @@ abstract class Field extends Data
|
|||
{
|
||||
return app(SingleValueMatcher::class);
|
||||
}
|
||||
|
||||
/** @param mixed $value */
|
||||
public function filter($value): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Form\Fields;
|
||||
|
||||
use App\Form\Contracts\Filterable;
|
||||
use App\Form\Matchers\Matcher;
|
||||
use App\Form\Matchers\SingleValueMatcher;
|
||||
use App\Form\Models\Form;
|
||||
|
@ -10,7 +9,7 @@ use App\Form\Models\Participant;
|
|||
use Faker\Generator;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class RadioField extends Field implements Filterable
|
||||
class RadioField extends Field
|
||||
{
|
||||
public bool $required;
|
||||
/** @var array<int, string> */
|
||||
|
@ -88,13 +87,4 @@ class RadioField extends Field implements Filterable
|
|||
{
|
||||
return app(SingleValueMatcher::class);
|
||||
}
|
||||
|
||||
public function filter($value): string
|
||||
{
|
||||
if (is_null($value)) {
|
||||
return "{$this->key} IS NULL";
|
||||
}
|
||||
|
||||
return $this->key . ' = \'' . $value . '\'';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Form\Actions\SettingStoreAction;
|
||||
use App\Setting\Contracts\Storeable;
|
||||
use App\Setting\LocalSettings;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
|
||||
class FormSettings extends LocalSettings implements Storeable
|
||||
{
|
||||
|
@ -32,23 +30,4 @@ class FormSettings extends LocalSettings implements Storeable
|
|||
'clearCacheUrl' => 'present|string',
|
||||
];
|
||||
}
|
||||
|
||||
public function beforeSave(ActionRequest $request): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function viewData(): array
|
||||
{
|
||||
return [
|
||||
'data' => [
|
||||
'data' => [
|
||||
'registerUrl' => $this->registerUrl,
|
||||
'clearCacheUrl' => $this->clearCacheUrl,
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,20 +2,17 @@
|
|||
|
||||
namespace App\Form\Models;
|
||||
|
||||
use App\Form\Actions\UpdateParticipantSearchIndexAction;
|
||||
use App\Form\Data\ExportData;
|
||||
use App\Form\Data\FieldCollection;
|
||||
use App\Form\Data\FormConfigData;
|
||||
use App\Lib\Editor\Condition;
|
||||
use App\Lib\Editor\EditorData;
|
||||
use App\Lib\Sorting;
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Database\Factories\Form\Models\FormFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Laravel\Scout\Searchable;
|
||||
use Spatie\Image\Enums\Fit;
|
||||
use Spatie\Image\Manipulations;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
|
@ -24,7 +21,6 @@ use Zoomyboy\MedialibraryHelper\DefersUploads;
|
|||
/** @todo replace editor content with EditorData cast */
|
||||
class Form extends Model implements HasMedia
|
||||
{
|
||||
/** @use HasFactory<FormFactory> */
|
||||
use HasFactory;
|
||||
use Sluggable;
|
||||
use InteractsWithMedia;
|
||||
|
@ -45,12 +41,11 @@ class Form extends Model implements HasMedia
|
|||
'needs_prevention' => 'boolean',
|
||||
'prevention_text' => EditorData::class,
|
||||
'prevention_conditions' => Condition::class,
|
||||
'from' => 'datetime',
|
||||
'to' => 'datetime',
|
||||
'registration_from' => 'datetime',
|
||||
'registration_until' => 'datetime',
|
||||
];
|
||||
|
||||
/** @var array<int, string> */
|
||||
public $dates = ['from', 'to', 'registration_from', 'registration_until'];
|
||||
|
||||
/**
|
||||
* @return SluggableConfig
|
||||
*/
|
||||
|
@ -78,7 +73,7 @@ class Form extends Model implements HasMedia
|
|||
->forceFileName(fn (Form $model, string $name) => $model->slug)
|
||||
->convert(fn () => 'jpg')
|
||||
->registerMediaConversions(function (Media $media) {
|
||||
$this->addMediaConversion('square')->fit(Fit::Crop, 400, 400);
|
||||
$this->addMediaConversion('square')->fit(Manipulations::FIT_CROP, 400, 400);
|
||||
});
|
||||
$this->addMediaCollection('mailattachments')
|
||||
->withDefaultProperties(fn () => [
|
||||
|
@ -160,7 +155,7 @@ class Form extends Model implements HasMedia
|
|||
if (is_null(data_get($model->meta, 'active_columns'))) {
|
||||
$model->setAttribute('meta', [
|
||||
'active_columns' => $model->getFields()->count() ? $model->getFields()->take(4)->pluck('key')->toArray() : null,
|
||||
'sorting' => Sorting::by('id'),
|
||||
'sorting' => $model->getFields()->count() ? [$model->getFields()->first()->key, 'asc'] : null,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
@ -173,32 +168,5 @@ class Form extends Model implements HasMedia
|
|||
return;
|
||||
}
|
||||
});
|
||||
|
||||
static::saved(function ($model) {
|
||||
UpdateParticipantSearchIndexAction::dispatch($model);
|
||||
});
|
||||
}
|
||||
|
||||
public function participantsSearchableAs(): string
|
||||
{
|
||||
return config('scout.prefix') . 'forms_' . $this->id . '_participants';
|
||||
}
|
||||
|
||||
public function defaultSorting(): Sorting
|
||||
{
|
||||
return Sorting::from($this->meta['sorting']);
|
||||
}
|
||||
|
||||
public function canRegister(): bool
|
||||
{
|
||||
if ($this->registration_from && $this->registration_from->gt(now())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->registration_until && $this->registration_until->lt(now())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace App\Form\Models;
|
|||
|
||||
use App\Form\Data\FormConfigData;
|
||||
use App\Lib\Editor\EditorData;
|
||||
use Database\Factories\Form\Models\FormtemplateFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
|
@ -13,7 +12,6 @@ use Illuminate\Database\Eloquent\Model;
|
|||
*/
|
||||
class Formtemplate extends Model
|
||||
{
|
||||
/** @use HasFactory<FormtemplateFactory> */
|
||||
use HasFactory;
|
||||
|
||||
public $guarded = [];
|
||||
|
|
|
@ -8,22 +8,17 @@ use App\Form\Mails\ConfirmRegistrationMail;
|
|||
use App\Form\Scopes\ParticipantFilterScope;
|
||||
use App\Member\Member;
|
||||
use App\Prevention\Contracts\Preventable;
|
||||
use Database\Factories\Form\Models\ParticipantFactory;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Laravel\Scout\Searchable;
|
||||
use stdClass;
|
||||
|
||||
class Participant extends Model implements Preventable
|
||||
{
|
||||
|
||||
/** @use HasFactory<ParticipantFactory> */
|
||||
use HasFactory;
|
||||
use Searchable;
|
||||
|
||||
public $guarded = [];
|
||||
|
||||
|
@ -48,6 +43,15 @@ class Participant extends Model implements Preventable
|
|||
return $this->hasMany(self::class, 'parent_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder<self> $query
|
||||
* @return Builder<self>
|
||||
*/
|
||||
public function scopeWithFilter(Builder $query, ParticipantFilterScope $filter): Builder
|
||||
{
|
||||
return $filter->apply($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Member, self>
|
||||
*/
|
||||
|
@ -103,15 +107,4 @@ class Participant extends Model implements Preventable
|
|||
{
|
||||
return 'Nachweise erforderlich für deine Anmeldung zu ' . $this->form->name;
|
||||
}
|
||||
|
||||
public function searchableAs(): string
|
||||
{
|
||||
return $this->form->participantsSearchableAs();
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
public function toSearchableArray(): array
|
||||
{
|
||||
return [...$this->data, 'parent-id' => $this->parent_id, 'created_at' => $this->created_at->timestamp];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ class FormApiResource extends JsonResource
|
|||
'image' => $this->getMedia('headerImage')->first()->getFullUrl('square'),
|
||||
'is_active' => $this->is_active,
|
||||
'is_private' => $this->is_private,
|
||||
'can_register' => $this->getModel()->canRegister(),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -4,76 +4,32 @@ namespace App\Form\Scopes;
|
|||
|
||||
use App\Form\Models\Form;
|
||||
use App\Form\Models\Participant;
|
||||
use App\Lib\ScoutFilter;
|
||||
use App\Lib\Sorting;
|
||||
use App\Lib\Filter;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Arr;
|
||||
use Laravel\Scout\Builder;
|
||||
use Spatie\LaravelData\Attributes\MapInputName;
|
||||
use Spatie\LaravelData\Attributes\MapOutputName;
|
||||
use Spatie\LaravelData\Mappers\SnakeCaseMapper;
|
||||
|
||||
/**
|
||||
* @extends ScoutFilter<Participant>
|
||||
* @extends Filter<Participant>
|
||||
*/
|
||||
#[MapInputName(SnakeCaseMapper::class)]
|
||||
#[MapOutputName(SnakeCaseMapper::class)]
|
||||
class ParticipantFilterScope extends ScoutFilter
|
||||
class ParticipantFilterScope extends Filter
|
||||
{
|
||||
|
||||
public static string $nan = 'deeb3ef4-d185-44b1-a4bc-0a4e7addebc3d8900c6f-a344-4afb-b54e-065ed483a7ba';
|
||||
private Form $form;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
* @param array<string, mixed> $options
|
||||
*/
|
||||
public function __construct(
|
||||
public array $data = [],
|
||||
public string $search = '',
|
||||
public array $options = [],
|
||||
public ?int $parent = null,
|
||||
public ?Sorting $sort = null
|
||||
) {
|
||||
}
|
||||
|
||||
public function getQuery(): Builder
|
||||
{
|
||||
$this->search = $this->search ?: '';
|
||||
|
||||
return Participant::search($this->search, function ($engine, string $query, array $options) {
|
||||
$filter = collect([]);
|
||||
|
||||
foreach ($this->form->getFields()->filterables() as $field) {
|
||||
if ($this->data[$field->key] === static::$nan) {
|
||||
continue;
|
||||
}
|
||||
$filter->push($field->filter($this->data[$field->key]));
|
||||
}
|
||||
|
||||
if ($this->parent === -1) {
|
||||
$filter->push('parent-id IS NULL');
|
||||
}
|
||||
|
||||
if ($this->parent !== null && $this->parent !== -1) {
|
||||
$filter->push('parent-id = ' . $this->parent);
|
||||
}
|
||||
|
||||
$options['filter'] = $filter->map(fn ($expression) => "($expression)")->implode(' AND ');
|
||||
|
||||
$options['sort'] = $this->sort->toMeilisearch();
|
||||
|
||||
return $engine->search($query, [...$this->options, ...$options]);
|
||||
})->within($this->form->participantsSearchableAs());
|
||||
}
|
||||
public static string $nan = 'deeb3ef4-d185-44b1-a4bc-0a4e7addebc3d8900c6f-a344-4afb-b54e-065ed483a7ba';
|
||||
|
||||
public function setForm(Form $form): self
|
||||
{
|
||||
$this->form = $form;
|
||||
|
||||
if (is_null($this->sort)) {
|
||||
$this->sort = $this->form->defaultSorting();
|
||||
}
|
||||
|
||||
foreach ($form->getFields() as $field) {
|
||||
if (!Arr::has($this->data, $field->key)) {
|
||||
data_set($this->data, $field->key, static::$nan);
|
||||
|
@ -83,10 +39,18 @@ class ParticipantFilterScope extends ScoutFilter
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function parent(?int $parent): self
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function apply(Builder $query): Builder
|
||||
{
|
||||
$this->parent = $parent;
|
||||
foreach ($this->data as $key => $value) {
|
||||
if ($value === static::$nan) {
|
||||
continue;
|
||||
}
|
||||
$query = $query->where('data->' . $key, $value);
|
||||
}
|
||||
|
||||
return $this;
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ namespace App\Form\Transformers;
|
|||
use App\Form\Fields\Field;
|
||||
use Illuminate\Support\Collection;
|
||||
use Spatie\LaravelData\Support\DataProperty;
|
||||
use Spatie\LaravelData\Support\Transformation\TransformationContext;
|
||||
use Spatie\LaravelData\Transformers\Transformer;
|
||||
|
||||
class CollectionTransformer implements Transformer
|
||||
|
@ -19,7 +18,7 @@ class CollectionTransformer implements Transformer
|
|||
* @param Collection<int, Field> $value
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function transform(DataProperty $property, mixed $value, TransformationContext $context): mixed
|
||||
public function transform(DataProperty $property, mixed $value): mixed
|
||||
{
|
||||
return $value->toArray();
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ namespace App\Form\Transformers;
|
|||
use App\Form\Fields\Field;
|
||||
use Illuminate\Support\Collection;
|
||||
use Spatie\LaravelData\Support\DataProperty;
|
||||
use Spatie\LaravelData\Support\Transformation\TransformationContext;
|
||||
use Spatie\LaravelData\Transformers\Transformer;
|
||||
|
||||
class FieldCollectionTransformer implements Transformer
|
||||
|
@ -15,7 +14,7 @@ class FieldCollectionTransformer implements Transformer
|
|||
* @param Collection<int, Field> $value
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function transform(DataProperty $property, mixed $value, TransformationContext $context): mixed
|
||||
public function transform(DataProperty $property, mixed $value): mixed
|
||||
{
|
||||
return $value->map(fn ($field) => [
|
||||
...$field->toArray(),
|
||||
|
|
|
@ -3,15 +3,12 @@
|
|||
namespace App;
|
||||
|
||||
use App\Nami\HasNamiField;
|
||||
use Database\Factories\GenderFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Gender extends Model
|
||||
{
|
||||
use HasNamiField;
|
||||
|
||||
/** @use HasFactory<GenderFactory> */
|
||||
use HasFactory;
|
||||
|
||||
public $fillable = ['name', 'nami_id'];
|
||||
|
@ -25,15 +22,6 @@ class Gender extends Model
|
|||
};
|
||||
}
|
||||
|
||||
public function getShortAttribute(): string
|
||||
{
|
||||
return match ($this->name) {
|
||||
'Männlich' => 'm',
|
||||
'Weiblich' => 'w',
|
||||
default => ''
|
||||
};
|
||||
}
|
||||
|
||||
public static function fromString(string $title): self
|
||||
{
|
||||
return self::firstWhere('name', $title);
|
||||
|
|
|
@ -5,7 +5,6 @@ namespace App;
|
|||
use App\Fileshare\Data\FileshareResourceData;
|
||||
use App\Group\Enums\Level;
|
||||
use App\Nami\HasNamiField;
|
||||
use Database\Factories\GroupFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
@ -13,7 +12,6 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||
|
||||
class Group extends Model
|
||||
{
|
||||
/** @use HasFactory<GroupFactory> */
|
||||
use HasFactory;
|
||||
use HasNamiField;
|
||||
|
||||
|
@ -26,11 +24,11 @@ class Group extends Model
|
|||
];
|
||||
|
||||
/**
|
||||
* @return BelongsTo<self, self>
|
||||
* @return BelongsTo<static, self>
|
||||
*/
|
||||
public function parent(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(self::class, 'parent_id');
|
||||
return $this->belongsTo(static::class, 'parent_id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,7 +36,7 @@ class Group extends Model
|
|||
*/
|
||||
public function children(): HasMany
|
||||
{
|
||||
return $this->hasMany(self::class, 'parent_id');
|
||||
return $this->hasMany(static::class, 'parent_id');
|
||||
}
|
||||
|
||||
public static function booted(): void
|
||||
|
|
|
@ -6,7 +6,6 @@ use App\Group;
|
|||
use App\Group\Resources\GroupResource;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class GroupApiIndexAction
|
||||
|
@ -21,12 +20,8 @@ class GroupApiIndexAction
|
|||
return Group::get();
|
||||
}
|
||||
|
||||
public function asController(ActionRequest $request, ?Group $group = null): AnonymousResourceCollection
|
||||
public function asController(?Group $group = null): AnonymousResourceCollection
|
||||
{
|
||||
return GroupResource::collection(
|
||||
$request->has('all')
|
||||
? Group::with('children')->get()
|
||||
: ($group ? $group->children()->withCount('children')->get() : Group::where('parent_id', null)->withCount('children')->get())
|
||||
);
|
||||
return GroupResource::collection($group ? $group->children()->withCount('children')->get() : Group::where('parent_id', null)->withCount('children')->get());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Lib\HasMeta;
|
||||
use App\User;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Storage;
|
||||
|
@ -11,6 +12,8 @@ use Storage;
|
|||
*/
|
||||
class UserResource extends JsonResource
|
||||
{
|
||||
use HasMeta;
|
||||
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
|
@ -25,9 +28,27 @@ class UserResource extends JsonResource
|
|||
'lastname' => $this->lastname,
|
||||
'avatar_url' => $this->getGravatarUrl(),
|
||||
'email' => $this->email,
|
||||
'id' => $this->id,
|
||||
'avatar' => [
|
||||
'src' => Storage::url('avatar.png'),
|
||||
],
|
||||
'links' => [
|
||||
'update' => route('user.update', ['user' => $this->getModel()]),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public static function meta(): array
|
||||
{
|
||||
return [
|
||||
'default' => [
|
||||
'firstname' => '',
|
||||
'lastname' => '',
|
||||
'email' => '',
|
||||
],
|
||||
'links' => [
|
||||
'store' => route('user.store'),
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@ use Lorisleiva\Actions\Concerns\AsAction;
|
|||
use App\Invoice\Models\Invoice;
|
||||
use App\Invoice\Resources\InvoiceResource;
|
||||
use App\Invoice\Scopes\InvoiceFilterScope;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
use Laravel\Scout\Builder;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
|
||||
class InvoiceIndexAction
|
||||
|
@ -17,11 +17,11 @@ class InvoiceIndexAction
|
|||
|
||||
|
||||
/**
|
||||
* @return Builder<Invoice>
|
||||
* @return LengthAwarePaginator<Invoice>
|
||||
*/
|
||||
public function handle(InvoiceFilterScope $filter): Builder
|
||||
public function handle(InvoiceFilterScope $filter): LengthAwarePaginator
|
||||
{
|
||||
return $filter->getQuery()->query(fn ($q) => $q->with('positions'));
|
||||
return Invoice::withFilter($filter)->with('positions')->paginate(15);
|
||||
}
|
||||
|
||||
public function asController(ActionRequest $request): Response
|
||||
|
@ -32,7 +32,7 @@ class InvoiceIndexAction
|
|||
$filter = InvoiceFilterScope::fromRequest($request->input('filter', ''));
|
||||
|
||||
return Inertia::render('invoice/Index', [
|
||||
'data' => InvoiceResource::collection($this->handle($filter)->paginate(15)),
|
||||
'data' => InvoiceResource::collection($this->handle($filter)),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ abstract class InvoiceDocument extends Document
|
|||
|
||||
public static function fromInvoice(Invoice $invoice): self
|
||||
{
|
||||
return static::factory()->withoutMagicalCreation()->from([
|
||||
return static::withoutMagicalCreationFrom([
|
||||
'toName' => $invoice->to['name'],
|
||||
'toAddress' => $invoice->to['address'],
|
||||
'toZip' => $invoice->to['zip'],
|
||||
|
|
|
@ -4,49 +4,36 @@ namespace App\Invoice;
|
|||
|
||||
use App\Setting\Contracts\Storeable;
|
||||
use App\Setting\LocalSettings;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
|
||||
class InvoiceSettings extends LocalSettings implements Storeable
|
||||
{
|
||||
public ?string $from_long;
|
||||
public ?string $from;
|
||||
public ?string $mobile;
|
||||
public ?string $email;
|
||||
public ?string $website;
|
||||
public ?string $address;
|
||||
public ?string $place;
|
||||
public ?string $zip;
|
||||
public ?string $iban;
|
||||
public ?string $bic;
|
||||
public ?int $rememberWeeks;
|
||||
public string $from_long;
|
||||
|
||||
public string $from;
|
||||
|
||||
public string $mobile;
|
||||
|
||||
public string $email;
|
||||
|
||||
public string $website;
|
||||
|
||||
public string $address;
|
||||
|
||||
public string $place;
|
||||
|
||||
public string $zip;
|
||||
|
||||
public string $iban;
|
||||
|
||||
public string $bic;
|
||||
|
||||
public int $rememberWeeks;
|
||||
|
||||
public static function group(): string
|
||||
{
|
||||
return 'bill';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function viewData(): array
|
||||
{
|
||||
return [
|
||||
'data' => [
|
||||
'from_long' => $this->from_long,
|
||||
'from' => $this->from,
|
||||
'mobile' => $this->mobile,
|
||||
'email' => $this->email,
|
||||
'website' => $this->website,
|
||||
'address' => $this->address,
|
||||
'place' => $this->place,
|
||||
'zip' => $this->zip,
|
||||
'iban' => $this->iban,
|
||||
'bic' => $this->bic,
|
||||
'rememberWeeks' => $this->rememberWeeks,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
|
@ -67,10 +54,6 @@ class InvoiceSettings extends LocalSettings implements Storeable
|
|||
];
|
||||
}
|
||||
|
||||
public function beforeSave(ActionRequest $request): void
|
||||
{
|
||||
}
|
||||
|
||||
public static function title(): string
|
||||
{
|
||||
return 'Rechnung';
|
||||
|
|
|
@ -11,20 +11,16 @@ use App\Invoice\RememberDocument;
|
|||
use App\Invoice\Scopes\InvoiceFilterScope;
|
||||
use App\Member\Member;
|
||||
use App\Payment\Subscription;
|
||||
use Database\Factories\Invoice\Models\InvoiceFactory;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Laravel\Scout\Searchable;
|
||||
use stdClass;
|
||||
|
||||
class Invoice extends Model
|
||||
{
|
||||
/** @use HasFactory<InvoiceFactory> */
|
||||
use HasFactory;
|
||||
use Searchable;
|
||||
|
||||
public $guarded = [];
|
||||
|
||||
|
@ -32,8 +28,12 @@ class Invoice extends Model
|
|||
'to' => 'json',
|
||||
'status' => InvoiceStatus::class,
|
||||
'via' => BillKind::class,
|
||||
'sent_at' => 'datetime',
|
||||
'last_remembered_at' => 'datetime',
|
||||
];
|
||||
|
||||
/** @var array<int, string> */
|
||||
public $dates = [
|
||||
'sent_at',
|
||||
'last_remembered_at',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -122,6 +122,15 @@ class Invoice extends Model
|
|||
->where('last_remembered_at', '<=', now()->subWeeks($weeks));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder<self> $query
|
||||
* @return Builder<self>
|
||||
*/
|
||||
public function scopeWithFilter(Builder $query, InvoiceFilterScope $filter): Builder
|
||||
{
|
||||
return $filter->apply($query);
|
||||
}
|
||||
|
||||
public function getMailRecipient(): stdClass
|
||||
{
|
||||
return (object) [
|
||||
|
@ -147,20 +156,4 @@ class Invoice extends Model
|
|||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the indexable data array for the model.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toSearchableArray(): array
|
||||
{
|
||||
return [
|
||||
'to' => implode(', ', $this->to),
|
||||
'usage' => $this->usage,
|
||||
'greeting' => $this->greeting,
|
||||
'mail_email' => $this->mail_email,
|
||||
'status' => $this->status->value,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,14 +3,12 @@
|
|||
namespace App\Invoice\Models;
|
||||
|
||||
use App\Member\Member;
|
||||
use Database\Factories\Invoice\Models\InvoicePositionFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class InvoicePosition extends Model
|
||||
{
|
||||
/** @use HasFactory<InvoicePositionFactory> */
|
||||
use HasFactory;
|
||||
|
||||
public $guarded = [];
|
||||
|
|
|
@ -5,43 +5,42 @@ namespace App\Invoice\Scopes;
|
|||
use App\Invoice\Enums\InvoiceStatus;
|
||||
use App\Invoice\Models\Invoice;
|
||||
use App\Lib\Filter;
|
||||
use App\Lib\ScoutFilter;
|
||||
use Laravel\Scout\Builder;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Spatie\LaravelData\Attributes\MapInputName;
|
||||
use Spatie\LaravelData\Attributes\MapOutputName;
|
||||
use Spatie\LaravelData\Mappers\SnakeCaseMapper;
|
||||
|
||||
/**
|
||||
* @extends ScoutFilter<Invoice>
|
||||
* @extends Filter<Invoice>
|
||||
*/
|
||||
#[MapInputName(SnakeCaseMapper::class)]
|
||||
#[MapOutputName(SnakeCaseMapper::class)]
|
||||
class InvoiceFilterScope extends ScoutFilter
|
||||
class InvoiceFilterScope extends Filter
|
||||
{
|
||||
/**
|
||||
* @param array<int, string> $statuses
|
||||
*/
|
||||
public function __construct(
|
||||
public ?array $statuses = null,
|
||||
public ?string $search = null
|
||||
) {
|
||||
$this->statuses = $this->statuses === null ? InvoiceStatus::defaultVisibleValues()->toArray() : $this->statuses;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getQuery(): Builder
|
||||
public function apply(Builder $query): Builder
|
||||
{
|
||||
$this->search = $this->search ?: '';
|
||||
$query = $query->whereIn('status', $this->statuses);
|
||||
|
||||
return Invoice::search($this->search, function ($engine, string $query, array $options) {
|
||||
if (empty($this->statuses)) {
|
||||
$filter = 'status = "asa6aeruuni4BahC7Wei6ahm1"';
|
||||
} else {
|
||||
$filter = collect($this->statuses)->map(fn (string $status) => "status = \"$status\"")->join(' OR ');
|
||||
}
|
||||
return $engine->search($query, [...$options, 'filter' => $filter]);
|
||||
});
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function toDefault(): self
|
||||
{
|
||||
$this->statuses = $this->statuses === null ? InvoiceStatus::defaultVisibleValues()->toArray() : $this->statuses;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,12 +20,12 @@ class Condition extends Data
|
|||
|
||||
public static function fromMedia(Media $media): self
|
||||
{
|
||||
return $media->getCustomProperty('conditions') ? static::factory()->withoutMagicalCreation()->from($media->getCustomProperty('conditions')) : static::defaults();
|
||||
return $media->getCustomProperty('conditions') ? static::withoutMagicalCreationFrom($media->getCustomProperty('conditions')) : static::defaults();
|
||||
}
|
||||
|
||||
public static function defaults(): self
|
||||
{
|
||||
return static::factory()->withoutMagicalCreation()->from(['mode' => 'any', 'ifs' => []]);
|
||||
return static::withoutMagicalCreationFrom(['mode' => 'any', 'ifs' => []]);
|
||||
}
|
||||
|
||||
public function hasStatements(): bool
|
||||
|
|
|
@ -20,7 +20,7 @@ abstract class ConditionResolver
|
|||
*/
|
||||
public function filterBlock(array $block): bool
|
||||
{
|
||||
return $this->filterCondition(Condition::factory()->withoutMagicalCreation()->from([
|
||||
return $this->filterCondition(Condition::withoutMagicalCreationFrom([
|
||||
'mode' => data_get($block, 'tunes.condition.mode', 'any'),
|
||||
'ifs' => data_get($block, 'tunes.condition.ifs', []),
|
||||
]));
|
||||
|
|
|
@ -36,7 +36,7 @@ abstract class Filter extends Data
|
|||
*/
|
||||
public static function fromPost(?array $post = null): static
|
||||
{
|
||||
return static::factory()->withoutMagicalCreation()->from($post ?: [])->toDefault();
|
||||
return static::withoutMagicalCreationFrom($post ?: [])->toDefault();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,11 +14,9 @@ abstract class ScoutFilter extends Data
|
|||
{
|
||||
|
||||
/**
|
||||
* @return Builder<T>
|
||||
* @return Builder
|
||||
*/
|
||||
abstract public function getQuery(): Builder;
|
||||
|
||||
/** @var Builder<T> */
|
||||
protected Builder $query;
|
||||
|
||||
/**
|
||||
|
@ -38,6 +36,6 @@ abstract class ScoutFilter extends Data
|
|||
*/
|
||||
public static function fromPost(?array $post = null): static
|
||||
{
|
||||
return static::factory()->withoutMagicalCreation()->from($post ?: []);
|
||||
return static::withoutMagicalCreationFrom($post ?: []);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Lib;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class Sorting extends Data
|
||||
{
|
||||
public static function by(string $by): self
|
||||
{
|
||||
return static::factory()->withoutMagicalCreation()->from(['by' => $by]);
|
||||
}
|
||||
|
||||
public function __construct(public string $by, public bool $direction = false)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function toMeilisearch(): array
|
||||
{
|
||||
return [$this->by . ':' . ($this->direction ? 'desc' : 'asc')];
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class Localmaildispatcher extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasUuids;
|
||||
|
||||
public $guarded = [];
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Maildispatcher\Models;
|
||||
|
||||
use App\Mailgateway\Models\Mailgateway;
|
||||
use Database\Factories\Maildispatcher\Models\MaildispatcherFactory;
|
||||
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
@ -11,7 +10,6 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|||
|
||||
class Maildispatcher extends Model
|
||||
{
|
||||
/** @use HasFactory<MaildispatcherFactory> */
|
||||
use HasFactory;
|
||||
use HasUuids;
|
||||
|
||||
|
|
|
@ -21,10 +21,8 @@ class MailgatewaySettings extends LocalSettings
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function viewData(): array
|
||||
public function data()
|
||||
{
|
||||
return [
|
||||
'data' => MailgatewayResource::collection(Mailgateway::paginate(10)),
|
||||
];
|
||||
return MailgatewayResource::collection(Mailgateway::paginate(10));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,14 +3,12 @@
|
|||
namespace App\Mailgateway\Models;
|
||||
|
||||
use App\Mailgateway\Casts\TypeCast;
|
||||
use Database\Factories\Mailgateway\Models\MailgatewayFactory;
|
||||
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Mailgateway extends Model
|
||||
{
|
||||
/** @use HasFactory<MailgatewayFactory> */
|
||||
use HasFactory;
|
||||
use HasUuids;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ class MailingList extends Data
|
|||
) {
|
||||
}
|
||||
|
||||
public static function toFactory(): MailinglistFactory
|
||||
public static function factory(): MailinglistFactory
|
||||
{
|
||||
return MailinglistFactory::new();
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ class NamiPutMemberAction
|
|||
'groupId' => $member->group->nami_id,
|
||||
'id' => $member->nami_id,
|
||||
'version' => $member->version,
|
||||
'keepdata' => $member->keepdata,
|
||||
'keepdata' => false,
|
||||
]);
|
||||
$response = $api->putMember($namiMember, $activity ? $activity->nami_id : null, $subactivity ? $subactivity->nami_id : null);
|
||||
Member::withoutEvents(function () use ($response, $member) {
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace App\Member\Data;
|
|||
use App\Group;
|
||||
use Illuminate\Support\Collection;
|
||||
use Spatie\LaravelData\Data;
|
||||
use Spatie\LaravelData\DataCollection;
|
||||
|
||||
class NestedGroup extends Data
|
||||
{
|
||||
|
@ -22,7 +23,7 @@ class NestedGroup extends Data
|
|||
$groups = collect([]);
|
||||
|
||||
foreach (Group::where('parent_id', $parentId)->orderBy('name')->get()->toBase() as $group) {
|
||||
$groups->push(['name' => str_repeat('- ', $level) . $group->name, 'id' => $group->id]);
|
||||
$groups->push(['name' => str_repeat('- ', $level).$group->name, 'id' => $group->id]);
|
||||
$groups = $groups->merge(static::forSelect($group->id, $level + 1));
|
||||
}
|
||||
|
||||
|
@ -30,10 +31,10 @@ class NestedGroup extends Data
|
|||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, static>
|
||||
* @return DataCollection<int, static>
|
||||
*/
|
||||
public static function cacheForSelect(): Collection
|
||||
public static function cacheForSelect(): DataCollection
|
||||
{
|
||||
return static::collect(static::forSelect());
|
||||
return static::collection(static::forSelect());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ use Zoomyboy\Osm\Geolocatable;
|
|||
use Zoomyboy\Osm\HasGeolocation;
|
||||
use Zoomyboy\Phone\HasPhoneNumbers;
|
||||
use App\Prevention\Enums\Prevention;
|
||||
use Database\Factories\Member\MemberFactory;
|
||||
|
||||
/**
|
||||
* @property string $subscription_name
|
||||
|
@ -43,7 +42,6 @@ class Member extends Model implements Geolocatable
|
|||
{
|
||||
use Notifiable;
|
||||
use HasNamiField;
|
||||
/** @use HasFactory<MemberFactory> */
|
||||
use HasFactory;
|
||||
use Sluggable;
|
||||
use Searchable;
|
||||
|
@ -58,7 +56,12 @@ class Member extends Model implements Geolocatable
|
|||
/**
|
||||
* @var array<int, string>
|
||||
*/
|
||||
public static array $namiFields = ['firstname', 'lastname', 'joined_at', 'birthday', 'send_newspaper', 'address', 'zip', 'location', 'nickname', 'other_country', 'further_address', 'main_phone', 'mobile_phone', 'work_phone', 'fax', 'email', 'email_parents', 'gender_id', 'confession_id', 'region_id', 'country_id', 'fee_id', 'nationality_id', 'slug', 'subscription_id', 'keepdata'];
|
||||
public static array $namiFields = ['firstname', 'lastname', 'joined_at', 'birthday', 'send_newspaper', 'address', 'zip', 'location', 'nickname', 'other_country', 'further_address', 'main_phone', 'mobile_phone', 'work_phone', 'fax', 'email', 'email_parents', 'gender_id', 'confession_id', 'region_id', 'country_id', 'fee_id', 'nationality_id', 'slug', 'subscription_id'];
|
||||
|
||||
/**
|
||||
* @var array<int, string>
|
||||
*/
|
||||
public $dates = ['try_created_at', 'recertified_at', 'joined_at', 'birthday', 'efz', 'ps_at', 'more_ps_at', 'without_education_at', 'without_efz_at'];
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
|
@ -77,19 +80,8 @@ class Member extends Model implements Geolocatable
|
|||
'multiply_pv' => 'boolean',
|
||||
'multiply_more_pv' => 'boolean',
|
||||
'is_leader' => 'boolean',
|
||||
'keepdata' => 'boolean',
|
||||
'bill_kind' => BillKind::class,
|
||||
'mitgliedsnr' => 'integer',
|
||||
|
||||
'try_created_at' => 'datetime',
|
||||
'recertified_at' => 'datetime',
|
||||
'joined_at' => 'datetime',
|
||||
'birthday' => 'datetime',
|
||||
'efz' => 'datetime',
|
||||
'ps_at' => 'datetime',
|
||||
'more_ps_at' => 'datetime',
|
||||
'without_education_at' => 'datetime',
|
||||
'without_efz_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -185,7 +177,7 @@ class Member extends Model implements Geolocatable
|
|||
|
||||
public function getAge(): ?int
|
||||
{
|
||||
return $this->birthday ? intval($this->birthday->diffInYears(now())) : null;
|
||||
return $this->birthday?->diffInYears(now());
|
||||
}
|
||||
|
||||
protected function getAusstand(): int
|
||||
|
@ -409,14 +401,14 @@ class Member extends Model implements Geolocatable
|
|||
return $query->where('group_id', $group->id);
|
||||
}
|
||||
|
||||
public static function fromVcard(string $url, string $data): self
|
||||
public static function fromVcard(string $url, string $data): static
|
||||
{
|
||||
$settings = app(NamiSettings::class);
|
||||
$card = Reader::read($data);
|
||||
[$lastname, $firstname] = $card->N->getParts();
|
||||
[$deprecated1, $deprecated2, $address, $location, $region, $zip, $country] = $card->ADR->getParts();
|
||||
|
||||
return new self([
|
||||
return new static([
|
||||
'joined_at' => now(),
|
||||
'send_newspaper' => false,
|
||||
'firstname' => $firstname,
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Member;
|
||||
|
||||
use App\Country;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Setting\NamiSettings;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
@ -32,7 +33,8 @@ class MemberController extends Controller
|
|||
session()->put('menu', 'member');
|
||||
session()->put('title', 'Mitglied erstellen');
|
||||
|
||||
return Inertia::render('member/VForm', [
|
||||
return \Inertia::render('member/VForm', [
|
||||
'data' => MemberResource::defaultModel(),
|
||||
'mode' => 'create',
|
||||
'meta' => MemberResource::meta(),
|
||||
]);
|
||||
|
@ -50,7 +52,7 @@ class MemberController extends Controller
|
|||
session()->put('menu', 'member');
|
||||
session()->put('title', "Mitglied {$member->firstname} {$member->lastname} bearbeiten");
|
||||
|
||||
return Inertia::render('member/VForm', [
|
||||
return \Inertia::render('member/VForm', [
|
||||
'data' => new MemberResource($member),
|
||||
'mode' => 'edit',
|
||||
'conflict' => '1' === $request->query('conflict', '0'),
|
||||
|
|
|
@ -83,7 +83,6 @@ class MemberRequest extends FormRequest
|
|||
'other_country' => '',
|
||||
'salutation' => '',
|
||||
'comment' => '',
|
||||
'keepdata' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,6 @@ class MemberResource extends JsonResource
|
|||
'lat' => $this->lat,
|
||||
'lon' => $this->lon,
|
||||
'group_name' => $this->group->name,
|
||||
'keepdata' => $this->keepdata,
|
||||
'links' => [
|
||||
'membership_index' => route('member.membership.index', ['member' => $this->getModel()]),
|
||||
'invoiceposition_index' => route('member.invoice-position.index', ['member' => $this->getModel()]),
|
||||
|
@ -163,48 +162,54 @@ class MemberResource extends JsonResource
|
|||
'activity_ids' => [],
|
||||
'subactivity_ids' => []
|
||||
],
|
||||
'default' => [
|
||||
'gender_id' => null,
|
||||
'salutation' => '',
|
||||
'nationality_id' => null,
|
||||
'firstname' => '',
|
||||
'lastname' => '',
|
||||
'address' => '',
|
||||
'further_address' => '',
|
||||
'zip' => '',
|
||||
'location' => '',
|
||||
'birthday' => '',
|
||||
'region_id' => null,
|
||||
'country_id' => Country::default(),
|
||||
'other_country' => '',
|
||||
'main_phone' => '',
|
||||
'mobile_phone' => '',
|
||||
'work_phone' => '',
|
||||
'children_phone' => '',
|
||||
'email' => '',
|
||||
'email_parents' => '',
|
||||
'fax' => '',
|
||||
'letter_address' => '',
|
||||
'bill_kind' => null,
|
||||
'subscription_id' => null,
|
||||
'has_nami' => false,
|
||||
'send_newspaper' => false,
|
||||
'joined_at' => now()->format('Y-m-d'),
|
||||
'comment' => '',
|
||||
'first_activity_id' => null,
|
||||
'first_subactivity_id' => null,
|
||||
'efz' => null,
|
||||
'ps_at' => null,
|
||||
'more_ps_at' => null,
|
||||
'without_education_at' => null,
|
||||
'recertified_at' => null,
|
||||
'without_efz_at' => null,
|
||||
'has_vk' => false,
|
||||
'has_svk' => false,
|
||||
'multiply_pv' => false,
|
||||
'multiply_more_pv' => false,
|
||||
'keepdata' => false,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function defaultModel(): array
|
||||
{
|
||||
return [
|
||||
'gender_id' => null,
|
||||
'salutation' => '',
|
||||
'nationality_id' => null,
|
||||
'firstname' => '',
|
||||
'lastname' => '',
|
||||
'address' => '',
|
||||
'further_address' => '',
|
||||
'zip' => '',
|
||||
'location' => '',
|
||||
'birthday' => '',
|
||||
'region_id' => null,
|
||||
'country_id' => Country::default(),
|
||||
'other_country' => '',
|
||||
'main_phone' => '',
|
||||
'mobile_phone' => '',
|
||||
'work_phone' => '',
|
||||
'children_phone' => '',
|
||||
'email' => '',
|
||||
'email_parents' => '',
|
||||
'fax' => '',
|
||||
'letter_address' => '',
|
||||
'bill_kind' => null,
|
||||
'subscription_id' => null,
|
||||
'has_nami' => false,
|
||||
'send_newspaper' => false,
|
||||
'joined_at' => now()->format('Y-m-d'),
|
||||
'comment' => '',
|
||||
'first_activity_id' => null,
|
||||
'first_subactivity_id' => null,
|
||||
'efz' => null,
|
||||
'ps_at' => null,
|
||||
'more_ps_at' => null,
|
||||
'without_education_at' => null,
|
||||
'recertified_at' => null,
|
||||
'without_efz_at' => null,
|
||||
'has_vk' => false,
|
||||
'has_svk' => false,
|
||||
'multiply_pv' => false,
|
||||
'multiply_more_pv' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ use App\Activity;
|
|||
use App\Group;
|
||||
use App\Nami\HasNamiField;
|
||||
use App\Subactivity;
|
||||
use Database\Factories\Member\MembershipFactory;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
@ -17,7 +16,6 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|||
*/
|
||||
class Membership extends Model
|
||||
{
|
||||
/** @use HasFactory<MembershipFactory> */
|
||||
use HasFactory;
|
||||
use HasNamiField;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ class PsPendingBlock extends Block
|
|||
})
|
||||
->whereCurrentGroup()
|
||||
->orderByRaw('lastname, firstname')
|
||||
->whereHas('memberships', fn ($builder) => $builder->isLeader()->active());
|
||||
->whereHas('memberships', fn ($builder) => $builder->isLeader());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,10 +27,6 @@ class ModuleSettings extends LocalSettings implements Storeable
|
|||
return in_array($module, $this->modules);
|
||||
}
|
||||
|
||||
public function beforeSave(ActionRequest $request): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
|
@ -45,14 +41,13 @@ class ModuleSettings extends LocalSettings implements Storeable
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function viewData(): array
|
||||
public function data(): array
|
||||
{
|
||||
return [
|
||||
'data' => [
|
||||
'data' => [
|
||||
'modules' => $this->modules,
|
||||
],
|
||||
'meta' => ['modules' => Module::forSelect()],
|
||||
...parent::data(),
|
||||
'meta' => [
|
||||
...parent::data()['meta'],
|
||||
'modules' => Module::forSelect(),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
|
|
@ -3,13 +3,11 @@
|
|||
namespace App;
|
||||
|
||||
use App\Nami\HasNamiField;
|
||||
use Database\Factories\NationalityFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Nationality extends Model
|
||||
{
|
||||
/** @use HasFactory<NationalityFactory> */
|
||||
use HasFactory;
|
||||
use HasNamiField;
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Payment;
|
||||
|
||||
use App\Fee;
|
||||
use Database\Factories\Payment\SubscriptionFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
@ -11,7 +10,6 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||
|
||||
class Subscription extends Model
|
||||
{
|
||||
/** @use HasFactory<SubscriptionFactory> */
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,14 +2,12 @@
|
|||
|
||||
namespace App\Payment;
|
||||
|
||||
use Database\Factories\Payment\SubscriptionChildFactory;
|
||||
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SubscriptionChild extends Model
|
||||
{
|
||||
/** @use HasFactory<SubscriptionChildFactory> */
|
||||
use HasFactory;
|
||||
use HasUuids;
|
||||
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Prevention\Actions;
|
||||
|
||||
use App\Prevention\PreventionSettings;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class SettingApiAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
public function handle(): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'data' => app(PreventionSettings::class)->toArray(),
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Prevention\Actions;
|
||||
|
||||
use App\Lib\Editor\EditorData;
|
||||
use App\Lib\Events\Succeeded;
|
||||
use App\Prevention\PreventionSettings;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class SettingStoreAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'formmail' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
public function handle(ActionRequest $request): void
|
||||
{
|
||||
$settings = app(PreventionSettings::class);
|
||||
$settings->formmail = EditorData::from($request->formmail);
|
||||
$settings->save();
|
||||
|
||||
Succeeded::message('Einstellungen gespeichert.')->dispatch();
|
||||
}
|
||||
}
|
|
@ -3,9 +3,11 @@
|
|||
namespace App\Prevention;
|
||||
|
||||
use App\Lib\Editor\EditorData;
|
||||
use App\Setting\Contracts\Storeable;
|
||||
use App\Setting\LocalSettings;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
|
||||
class PreventionSettings extends LocalSettings
|
||||
class PreventionSettings extends LocalSettings implements Storeable
|
||||
{
|
||||
|
||||
public EditorData $formmail;
|
||||
|
@ -23,8 +25,17 @@ class PreventionSettings extends LocalSettings
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function viewData(): array
|
||||
public function rules(): array
|
||||
{
|
||||
return [];
|
||||
return [
|
||||
'formmail' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
public function saveAttributes(ActionRequest $request): array
|
||||
{
|
||||
return [
|
||||
'formmail' => EditorData::from($request->formmail),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ class AppServiceProvider extends ServiceProvider
|
|||
public function register()
|
||||
{
|
||||
JsonResource::withoutWrapping();
|
||||
Telescope::ignoreMigrations();
|
||||
|
||||
\Inertia::share('search', request()->query('search', ''));
|
||||
|
||||
|
|
|
@ -2,14 +2,12 @@
|
|||
|
||||
namespace App;
|
||||
|
||||
use Database\Factories\RegionFactory;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Region extends Model
|
||||
{
|
||||
/** @use HasFactory<RegionFactory> */
|
||||
use HasFactory;
|
||||
public $timestamps = false;
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace App\Setting\Actions;
|
||||
|
||||
use App\Lib\Events\Succeeded;
|
||||
use App\Setting\Contracts\Storeable;
|
||||
use GrahamCampbell\ResultType\Success;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
@ -33,7 +35,9 @@ class StoreAction
|
|||
public function asController(ActionRequest $request, Storeable $settingGroup): RedirectResponse
|
||||
{
|
||||
$settingGroup->beforeSave($request);
|
||||
$this->handle($settingGroup, $request->validated());
|
||||
$this->handle($settingGroup, $settingGroup->saveAttributes($request));
|
||||
|
||||
Succeeded::message('Einstellungen gespeichert')->dispatch();
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ class ViewAction
|
|||
session()->put('title', $settingGroup::title());
|
||||
|
||||
return Inertia::render('setting/' . ucfirst($settingGroup::group()), [
|
||||
...$settingGroup->viewData(),
|
||||
'setting_menu' => app(SettingFactory::class)->getShare(),
|
||||
'data' => $settingGroup->data(),
|
||||
'settingMenu' => app(SettingFactory::class)->getShare(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,4 +24,6 @@ interface Storeable
|
|||
public function rules(): array;
|
||||
|
||||
public function beforeSave(ActionRequest $request): void;
|
||||
|
||||
public function saveAttributes(ActionRequest $request): array;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Setting;
|
||||
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Spatie\LaravelSettings\Settings;
|
||||
|
||||
abstract class LocalSettings extends Settings
|
||||
|
@ -13,8 +14,36 @@ abstract class LocalSettings extends Settings
|
|||
return route('setting.view', ['settingGroup' => $this->group()]);
|
||||
}
|
||||
|
||||
public function storeUrl(): string
|
||||
{
|
||||
return $this->url();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function data()
|
||||
{
|
||||
return [
|
||||
'data' => $this->toArray(),
|
||||
'meta' => [
|
||||
'links' => [
|
||||
'store' => $this->storeUrl(),
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function beforeSave(ActionRequest $request): void
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
abstract public function viewData(): array;
|
||||
public function saveAttributes(ActionRequest $request): array
|
||||
{
|
||||
return $request->validated();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace App\Setting;
|
|||
|
||||
use App\Group;
|
||||
use App\Initialize\Actions\NamiLoginCheckAction;
|
||||
use App\Nami\Actions\SettingSaveAction;
|
||||
use App\Setting\Contracts\Storeable;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Zoomyboy\LaravelNami\Api;
|
||||
|
@ -64,14 +63,15 @@ class NamiSettings extends LocalSettings implements Storeable
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function viewData(): array
|
||||
public function data(): array
|
||||
{
|
||||
return [
|
||||
...parent::data(),
|
||||
'data' => [
|
||||
'mglnr' => $this->mglnr,
|
||||
'password' => '',
|
||||
'default_group_id' => $this->default_group_id,
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace App\Setting;
|
||||
|
||||
use App\Invoice\InvoiceSettings;
|
||||
use App\Setting\Contracts\Storeable;
|
||||
use Illuminate\Routing\Router;
|
||||
|
||||
class SettingFactory
|
||||
|
|
|
@ -10,6 +10,7 @@ use App\Module\ModuleSettings;
|
|||
use App\Prevention\PreventionSettings;
|
||||
use App\Setting\Actions\StoreAction;
|
||||
use App\Setting\Actions\ViewAction;
|
||||
use App\User\UserSettings;
|
||||
use Illuminate\Routing\Router;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
|
@ -43,5 +44,6 @@ class SettingServiceProvider extends ServiceProvider
|
|||
app(SettingFactory::class)->register(FormSettings::class);
|
||||
app(SettingFactory::class)->register(FileshareSettings::class);
|
||||
app(SettingFactory::class)->register(PreventionSettings::class);
|
||||
app(SettingFactory::class)->register(UserSettings::class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,14 +4,12 @@ namespace App;
|
|||
|
||||
use App\Nami\HasNamiField;
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Database\Factories\UserFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Subactivity extends Model
|
||||
{
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory;
|
||||
use HasNamiField;
|
||||
use Sluggable;
|
||||
|
|
|
@ -3,14 +3,12 @@
|
|||
namespace App;
|
||||
|
||||
use App\Auth\ResetPassword;
|
||||
use Database\Factories\UserFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory;
|
||||
use Notifiable;
|
||||
|
||||
|
@ -29,4 +27,9 @@ class User extends Authenticatable
|
|||
{
|
||||
return 'https://www.gravatar.com/avatar/' . hash('sha256', $this->email);
|
||||
}
|
||||
|
||||
public function getFullname(): string
|
||||
{
|
||||
return $this->firstname . ' ' . $this->lastname;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace App\User\Actions;
|
||||
|
||||
use App\User;
|
||||
use App\User\Mail\WelcomeMail;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class StoreAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'firstname' => 'required|string|max:255',
|
||||
'lastname' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255|unique:users,email',
|
||||
];
|
||||
}
|
||||
|
||||
public function handle(ActionRequest $request): JsonResponse
|
||||
{
|
||||
User::create([
|
||||
...$request->validated(),
|
||||
'password' => Hash::make(str()->random(32)),
|
||||
]);
|
||||
|
||||
Password::broker()->sendResetLink(
|
||||
$request->safe()->only('email'),
|
||||
fn ($user, $token) => Mail::to($user)->send(new WelcomeMail($user, $token))
|
||||
);
|
||||
|
||||
return response()->json([]);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue