47 lines
963 B
PHP
47 lines
963 B
PHP
<?php
|
|
|
|
namespace App\Pdf;
|
|
|
|
use App\Member\Member;
|
|
use Carbon\Carbon;
|
|
use Generator;
|
|
use Illuminate\Support\Collection;
|
|
|
|
abstract class Repository
|
|
{
|
|
abstract public function getPayments(Member $member): Collection;
|
|
|
|
public Collection $pages;
|
|
|
|
public function __construct(Collection $pages)
|
|
{
|
|
$this->pages = $pages;
|
|
}
|
|
|
|
public function number(int $number): string
|
|
{
|
|
return number_format($number / 100, 2, '.', '');
|
|
}
|
|
|
|
public function getUntil(): Carbon
|
|
{
|
|
return now()->addWeeks(2);
|
|
}
|
|
|
|
public function createable(Member $member): bool
|
|
{
|
|
return 0 !== $this->getPayments($member)->count();
|
|
}
|
|
|
|
public function allPayments(): Generator
|
|
{
|
|
foreach ($this->pages as $page) {
|
|
foreach ($page as $member) {
|
|
foreach ($this->getPayments($member) as $payment) {
|
|
yield $payment;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|