diff --git a/app/Contribution/Data/MemberData.php b/app/Contribution/Data/MemberData.php index b562b421..b5882564 100644 --- a/app/Contribution/Data/MemberData.php +++ b/app/Contribution/Data/MemberData.php @@ -72,9 +72,9 @@ class MemberData extends Data return $this->zip . ' ' . $this->location; } - public function age(): string + public function age(): int { - return $this->birthday ? intval($this->birthday->diffInYears(now())) : ''; + return intval($this->birthday->diffInYears(now())); } public function birthYear(): string diff --git a/app/Contribution/Documents/RdpNrwDocument.php b/app/Contribution/Documents/RdpNrwDocument.php index 248e21e7..1672d6d1 100644 --- a/app/Contribution/Documents/RdpNrwDocument.php +++ b/app/Contribution/Documents/RdpNrwDocument.php @@ -3,14 +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 Carbon\Carbon; use Illuminate\Support\Collection; class RdpNrwDocument extends ContributionDocument { use HasPdfBackground; + use FormatsDates; /** * @param Collection> $members @@ -28,13 +29,6 @@ class RdpNrwDocument extends ContributionDocument $this->setEventName($eventName); } - public function dateRange(): string - { - return Carbon::parse($this->dateFrom)->format('d.m.Y') - . ' - ' - . Carbon::parse($this->dateUntil)->format('d.m.Y'); - } - /** * {@inheritdoc} */ @@ -70,35 +64,6 @@ 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 static function getName(): string { return 'RdP NRW'; diff --git a/app/Contribution/Traits/FormatsDates.php b/app/Contribution/Traits/FormatsDates.php index bc2f9360..242e7436 100644 --- a/app/Contribution/Traits/FormatsDates.php +++ b/app/Contribution/Traits/FormatsDates.php @@ -16,4 +16,9 @@ trait FormatsDates { return Carbon::parse($this->dateUntil)->format('d.m.Y'); } + + public function dateRange(): string + { + return implode(' - ', [$this->niceDateFrom(), $this->niceDateUntil()]); + } } diff --git a/resources/views/tex/contribution/rdp-nrw.tex b/resources/views/tex/contribution/rdp-nrw.tex index f5c907db..362d433e 100644 --- a/resources/views/tex/contribution/rdp-nrw.tex +++ b/resources/views/tex/contribution/rdp-nrw.tex @@ -23,11 +23,11 @@ @foreach($chunk as $i => $member) \node[anchor=base, text width=7.75mm, align=center] at ($(16.35mm, 76.6mm + 7mm * <<<$i % 17>>>)$) {<<<$i+1>>>}; - \node[anchor=base, text width=18mm, align=center] at ($(32.55mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$memberShort($member)>>>}; - \node[anchor=base, text width=70mm, align=center] at ($(80.25mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$memberName($member)>>>}; - \node[anchor=base, text width=118mm, align=center] at ($(178.25mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$memberAddress($member)>>>}; - \node[anchor=base, text width=16mm, align=center] at ($(249.50mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$memberGender($member)>>>}; - \node[anchor=base, text width=16mm, align=center] at ($(269.50mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$memberAge($member)>>>}; + \node[anchor=base, text width=18mm, align=center] at ($(32.55mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$member->isLeader ? 'L' : ''>>>}; + \node[anchor=base, text width=70mm, align=center] at ($(80.25mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$member->separatedName()>>>}; + \node[anchor=base, text width=118mm, align=center] at ($(178.25mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$member->fullAddress()>>>}; + \node[anchor=base, text width=16mm, align=center] at ($(249.50mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$member->genderLetter()>>>}; + \node[anchor=base, text width=16mm, align=center] at ($(269.50mm, 76.6mm + 7mm * <<<$i%17>>>)$) {<<<$member->age()>>>}; @endforeach \end{tikzpicture}