2023-03-14 22:29:39 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\RequestFactories;
|
|
|
|
|
|
|
|
use App\Contribution\ContributionFactory;
|
|
|
|
use App\Contribution\Documents\ContributionDocument;
|
|
|
|
use App\Country;
|
|
|
|
use App\Member\Member;
|
|
|
|
use Worksome\RequestFactories\RequestFactory;
|
|
|
|
|
|
|
|
class ContributionRequestFactory extends RequestFactory
|
|
|
|
{
|
|
|
|
public function definition(): array
|
|
|
|
{
|
|
|
|
$compilers = collect(app(ContributionFactory::class)->compilerSelect())->pluck('class');
|
|
|
|
|
|
|
|
return [
|
2023-10-27 00:48:50 +02:00
|
|
|
'country' => Country::factory()->create()->id,
|
2023-03-14 22:29:39 +01:00
|
|
|
'dateFrom' => $this->faker->date(),
|
|
|
|
'dateUntil' => $this->faker->date(),
|
|
|
|
'eventName' => $this->faker->words(3, true),
|
2023-10-27 00:48:50 +02:00
|
|
|
'members' => [Member::factory()->defaults()->create()->id],
|
2023-03-14 22:29:39 +01:00
|
|
|
'type' => $this->faker->randomElement($compilers),
|
|
|
|
'zipLocation' => $this->faker->city,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function toBase64(): string
|
|
|
|
{
|
2023-10-30 23:11:10 +01:00
|
|
|
return base64_encode(rawurlencode(json_encode($this->create())));
|
2023-03-14 22:29:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param class-string<ContributionDocument> $type
|
|
|
|
*/
|
|
|
|
public function type(string $type): self
|
|
|
|
{
|
|
|
|
return $this->state(['type' => $type]);
|
|
|
|
}
|
|
|
|
}
|