adrema/app/Invoice/DocumentFactory.php

38 lines
769 B
PHP
Raw Normal View History

2022-11-07 16:18:11 +01:00
<?php
2023-04-18 22:08:45 +02:00
namespace App\Invoice;
2022-11-07 16:18:11 +01:00
2023-11-30 23:54:16 +01:00
use App\Member\Member;
2022-11-07 16:18:11 +01:00
use Illuminate\Support\Collection;
class DocumentFactory
{
/**
2023-04-18 22:08:45 +02:00
* @var array<int, class-string<Invoice>>
2022-11-07 16:18:11 +01:00
*/
2022-12-07 00:40:53 +01:00
private array $types = [
2022-11-07 16:18:11 +01:00
BillDocument::class,
RememberDocument::class,
];
/**
2023-04-18 22:08:45 +02:00
* @return Collection<int, class-string<Invoice>>
2022-11-07 16:18:11 +01:00
*/
public function getTypes(): Collection
{
2022-12-07 00:40:53 +01:00
return collect($this->types);
2022-11-07 16:18:11 +01:00
}
/**
2023-11-30 23:54:16 +01:00
* @param Collection<(int|string), Member> $members
2022-11-07 16:18:11 +01:00
*/
2023-11-30 23:54:16 +01:00
public function afterSingle(Invoice $invoice, Collection $members): void
2022-11-07 16:18:11 +01:00
{
2023-11-30 23:54:16 +01:00
foreach ($members as $member) {
foreach ($member->payments as $payment) {
$invoice->afterSingle($payment);
}
2022-11-07 16:18:11 +01:00
}
}
}