Add validation

This commit is contained in:
philipp lang 2024-12-13 01:59:09 +01:00
parent 4690e86bbf
commit 52ac5937a4
5 changed files with 44 additions and 42 deletions

View File

@ -81,4 +81,14 @@ class MemberData extends Data
{
return (string) $this->birthday->year;
}
public function birthdayHuman(): string
{
return $this->birthday->format('d.m.Y');
}
public function genderLetter(): string
{
return $this->gender->short;
}
}

View File

@ -25,11 +25,14 @@ class GallierDocument extends ContributionDocument
) {
}
public function dateRange(): string
public function dateFromHuman(): string
{
return Carbon::parse($this->dateFrom)->format('d.m.Y')
. ' - '
. Carbon::parse($this->dateUntil)->format('d.m.Y');
return Carbon::parse($this->dateFrom)->format('d.m.Y');
}
public function dateUntilHuman(): string
{
return Carbon::parse($this->dateUntil)->format('d.m.Y');
}
/**
@ -60,40 +63,6 @@ class GallierDocument extends ContributionDocument
);
}
public function countryName(): string
{
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-gallier';
@ -123,7 +92,7 @@ class GallierDocument extends ContributionDocument
public static function getName(): string
{
return 'Für RdP NRW erstellen';
return 'Für Gallier erstellen';
}
/**
@ -134,9 +103,7 @@ class GallierDocument extends ContributionDocument
return [
'dateFrom' => 'required|string|date_format:Y-m-d',
'dateUntil' => 'required|string|date_format:Y-m-d',
'country' => 'required|integer|exists:countries,id',
'zipLocation' => 'required|string',
'eventName' => 'required|string',
];
}
}

View File

@ -25,6 +25,15 @@ class Gender extends Model
};
}
public function getShortAttribute(): string
{
return match ($this->name) {
'Männlich' => 'm',
'Weiblich' => 'w',
default => ''
};
}
public static function fromString(string $title): self
{
return self::firstWhere('name', $title);

View File

@ -28,7 +28,7 @@
\node[anchor=center, text width=45.75mm, align=center] at ($(135.35mm, 59.7mm + 9.2mm * <<<$i%14>>>)$) {<<<$member->address>>>};
\node[anchor=center, text width=26.75mm, align=center] at ($(174.35mm, 59.7mm + 9.2mm * <<<$i%14>>>)$) {<<<$member->city()>>>};
\node[anchor=center, text width=19.75mm, align=center] at ($(199.35mm, 59.7mm + 9.2mm * <<<$i%14>>>)$) {<<<$member->birthdayHuman()>>>};
\node[anchor=center, text width=7.75mm, align=center] at ($(216.35mm, 59.7mm + 9.2mm * <<<$i%14>>>)$) {<<<$member->gender?->short>>>};
\node[anchor=center, text width=7.75mm, align=center] at ($(216.35mm, 59.7mm + 9.2mm * <<<$i%14>>>)$) {<<<$member->genderLetter()>>>};
\node[anchor=center, text width=7.75mm, align=center] at ($(276.35mm, 59.7mm + 9.2mm * <<<$i%14>>>)$) {<<<$member->isLeader ? 'GL' : 'T'>>>};
@endforeach

View File

@ -5,6 +5,7 @@ namespace Tests\Feature\Contribution;
use App\Contribution\Documents\ContributionDocument;
use App\Contribution\Documents\RdpNrwDocument;
use App\Contribution\Documents\CitySolingenDocument;
use App\Contribution\Documents\GallierDocument;
use App\Country;
use App\Gender;
use App\Invoice\InvoiceSettings;
@ -89,6 +90,21 @@ dataset('validation', function () {
CitySolingenDocument::class,
'zipLocation',
],
[
['zipLocation' => ''],
GallierDocument::class,
'zipLocation',
],
[
['dateFrom' => ''],
GallierDocument::class,
'dateFrom',
],
[
['dateUntil' => ''],
GallierDocument::class,
'dateUntil',
],
];
});