2021-07-17 15:25:50 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Pdf;
|
|
|
|
|
2021-07-17 19:21:27 +02:00
|
|
|
use App\Member\Member;
|
2021-07-17 17:13:16 +02:00
|
|
|
use Carbon\Carbon;
|
2021-07-17 19:21:27 +02:00
|
|
|
use Generator;
|
2022-01-02 12:32:57 +01:00
|
|
|
use Illuminate\Support\Collection;
|
2021-07-17 17:13:16 +02:00
|
|
|
|
2021-07-17 15:25:50 +02:00
|
|
|
abstract class Repository
|
|
|
|
{
|
|
|
|
|
2022-01-02 12:32:57 +01:00
|
|
|
abstract public function getPayments(Member $member): Collection;
|
|
|
|
|
|
|
|
public Collection $pages;
|
|
|
|
|
|
|
|
public function __construct(Collection $pages)
|
|
|
|
{
|
|
|
|
$this->pages = $pages;
|
|
|
|
}
|
|
|
|
|
2021-07-17 15:25:50 +02:00
|
|
|
public function number(int $number): string
|
|
|
|
{
|
|
|
|
return number_format($number / 100, 2, '.', '');
|
|
|
|
}
|
|
|
|
|
2021-07-17 17:13:16 +02:00
|
|
|
public function getUntil(): Carbon
|
|
|
|
{
|
|
|
|
return now()->addWeeks(2);
|
|
|
|
}
|
|
|
|
|
2021-07-17 19:21:27 +02:00
|
|
|
public function createable(Member $member): bool
|
|
|
|
{
|
|
|
|
return $this->getPayments($member)->count() !== 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function allPayments(): Generator
|
|
|
|
{
|
|
|
|
foreach ($this->pages as $page) {
|
|
|
|
foreach ($page as $member) {
|
|
|
|
foreach ($this->getPayments($member) as $payment) {
|
|
|
|
yield $payment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-17 15:25:50 +02:00
|
|
|
}
|