adrema/app/Payment/ActionFactory.php

36 lines
1.0 KiB
PHP
Raw Normal View History

2021-07-17 16:57:37 +02:00
<?php
namespace App\Payment;
use App\Member\Member;
2022-02-12 16:44:43 +01:00
use App\Pdf\PdfRepository;
2021-07-17 16:57:37 +02:00
use App\Pdf\PdfRepositoryFactory;
use Illuminate\Support\Collection;
class ActionFactory
{
public function forMember(Member $member): Collection
{
2022-03-11 20:19:17 +01:00
return app(PdfRepositoryFactory::class)->getTypes()->map(function (PdfRepository $repo) use ($member): array {
2021-07-17 16:57:37 +02:00
return [
'href' => route('member.singlepdf', ['member' => $member, 'type' => get_class($repo)]),
'label' => $repo->linkLabel(),
'disabled' => !$repo->createable($member),
];
});
}
2021-07-17 18:46:02 +02:00
public function allLinks(): Collection
{
2022-03-11 20:19:17 +01:00
return app(PdfRepositoryFactory::class)->getTypes()->map(function (PdfRepository $repo) {
2021-07-17 18:46:02 +02:00
return [
2021-10-29 21:44:23 +02:00
'link' => [
'href' => route('sendpayment.pdf', ['type' => get_class($repo)]),
'label' => $repo->allLabel(),
],
'text' => $repo->getDescription(),
2021-07-17 18:46:02 +02:00
];
});
}
2021-07-17 16:57:37 +02:00
}