2022-11-29 17:14:31 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Zoomyboy\LaravelNami\Tests\Factories;
|
|
|
|
|
2023-02-12 22:39:53 +01:00
|
|
|
use GuzzleHttp\Promise\PromiseInterface;
|
2022-11-29 17:14:31 +01:00
|
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
use Worksome\RequestFactories\RequestFactory;
|
2023-02-06 00:23:34 +01:00
|
|
|
use Zoomyboy\LaravelNami\Data\Member;
|
2022-11-29 17:14:31 +01:00
|
|
|
|
|
|
|
class MemberRequestFactory extends RequestFactory
|
|
|
|
{
|
2023-02-12 22:39:53 +01:00
|
|
|
/**
|
|
|
|
* @return array<string, mixed>
|
|
|
|
*/
|
2022-11-29 17:14:31 +01:00
|
|
|
public function definition(): array
|
|
|
|
{
|
|
|
|
return [
|
2023-02-06 00:23:34 +01:00
|
|
|
'firstname' => $this->faker->firstName,
|
|
|
|
'lastname' => $this->faker->lastName,
|
2022-11-29 17:14:31 +01:00
|
|
|
'nickname' => $this->faker->firstName,
|
2023-02-06 00:23:34 +01:00
|
|
|
'groupId' => $this->faker->numberBetween(100, 200),
|
|
|
|
'genderId' => $this->faker->numberBetween(100, 200),
|
|
|
|
'confessionId' => $this->faker->numberBetween(100, 200),
|
|
|
|
'joinedAt' => $this->faker->dateTime()->format('Y-m-d').' 00:00:00',
|
|
|
|
'birthday' => $this->faker->dateTime()->format('Y-m-d').' 00:00:00',
|
|
|
|
'email' => $this->faker->safeEmail(),
|
|
|
|
'countryId' => $this->faker->numberBetween(100, 200),
|
|
|
|
'keepdata' => $this->faker->boolean(),
|
|
|
|
'sendNewspaper' => $this->faker->boolean(),
|
|
|
|
'regionId' => $this->faker->numberBetween(100, 200),
|
|
|
|
'nationalityId' => $this->faker->numberBetween(100, 200),
|
|
|
|
'beitragsartId' => $this->faker->numberBetween(100, 200),
|
|
|
|
'id' => null,
|
2022-11-29 17:14:31 +01:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2023-02-06 00:23:34 +01:00
|
|
|
public function inNami(int $groupId, int $namiId): self
|
|
|
|
{
|
|
|
|
return $this->state([
|
|
|
|
'id' => $namiId,
|
|
|
|
'groupId' => $groupId,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2022-11-29 17:19:00 +01:00
|
|
|
public function withEmptyNames(): self
|
|
|
|
{
|
|
|
|
return $this->state([
|
|
|
|
'vorname' => '',
|
|
|
|
'nachname' => '',
|
|
|
|
'nickname' => '',
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2023-02-12 22:39:53 +01:00
|
|
|
public function toSingleHttp(): PromiseInterface
|
2022-11-29 17:14:31 +01:00
|
|
|
{
|
2022-11-29 17:19:00 +01:00
|
|
|
return Http::response(json_encode([
|
|
|
|
'success' => true,
|
|
|
|
'message' => null,
|
|
|
|
'title' => null,
|
|
|
|
'data' => $this->create(),
|
|
|
|
'responseType' => null,
|
|
|
|
]), 200);
|
2022-11-29 17:14:31 +01:00
|
|
|
}
|
2023-02-06 00:23:34 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array<string, mixed> $attributes
|
|
|
|
*/
|
|
|
|
public function toMember(array $attributes = []): Member
|
|
|
|
{
|
|
|
|
return Member::from($this->create($attributes));
|
|
|
|
}
|
2022-11-29 17:14:31 +01:00
|
|
|
}
|