2022-11-17 21:47:45 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Contribution;
|
|
|
|
|
2023-09-07 13:03:15 +02:00
|
|
|
use App\Contribution\Documents\BdkjHesse;
|
2022-11-17 21:47:45 +01:00
|
|
|
use App\Contribution\Documents\ContributionDocument;
|
2023-09-07 12:04:13 +02:00
|
|
|
use App\Contribution\Documents\RdpNrwDocument;
|
|
|
|
use App\Contribution\Documents\CityRemscheidDocument;
|
|
|
|
use App\Contribution\Documents\CitySolingenDocument;
|
2023-09-07 12:46:35 +02:00
|
|
|
use App\Contribution\Documents\CityFrankfurtMainDocument;
|
2024-12-13 19:03:40 +01:00
|
|
|
use App\Contribution\Documents\WuppertalDocument;
|
2023-03-14 22:29:39 +01:00
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
use Illuminate\Validation\Rule;
|
2022-11-17 21:47:45 +01:00
|
|
|
|
|
|
|
class ContributionFactory
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var array<int, class-string<ContributionDocument>>
|
|
|
|
*/
|
|
|
|
private array $documents = [
|
2023-09-07 12:04:13 +02:00
|
|
|
RdpNrwDocument::class,
|
|
|
|
CitySolingenDocument::class,
|
|
|
|
CityRemscheidDocument::class,
|
2023-09-07 12:46:35 +02:00
|
|
|
CityFrankfurtMainDocument::class,
|
2023-09-07 13:03:15 +02:00
|
|
|
BdkjHesse::class,
|
2024-12-13 19:03:40 +01:00
|
|
|
WuppertalDocument::class,
|
2022-11-17 21:47:45 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
2024-06-29 11:18:40 +02:00
|
|
|
* @return Collection<int, array{title: string, class: class-string<ContributionDocument>}>
|
2022-11-17 21:47:45 +01:00
|
|
|
*/
|
2023-03-14 22:29:39 +01:00
|
|
|
public function compilerSelect(): Collection
|
2022-11-17 21:47:45 +01:00
|
|
|
{
|
|
|
|
return collect($this->documents)->map(fn ($document) => [
|
2024-12-13 02:16:09 +01:00
|
|
|
'title' => $document::buttonName(),
|
2022-11-17 21:47:45 +01:00
|
|
|
'class' => $document,
|
2023-03-14 22:29:39 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array<string, mixed>
|
|
|
|
*/
|
|
|
|
public function typeRule(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'type' => ['required', Rule::in($this->documents)],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param class-string<ContributionDocument> $type
|
|
|
|
*
|
|
|
|
* @return array<string, mixed>
|
|
|
|
*/
|
|
|
|
public function rules(string $type): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
...$type::globalRules(),
|
|
|
|
...$type::rules(),
|
|
|
|
];
|
2022-11-17 21:47:45 +01:00
|
|
|
}
|
|
|
|
}
|