2021-06-13 11:33:50 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Database\Factories\Member;
|
|
|
|
|
2021-07-17 15:58:38 +02:00
|
|
|
use App\Country;
|
|
|
|
use App\Fee;
|
|
|
|
use App\Group;
|
2023-04-18 22:08:45 +02:00
|
|
|
use App\Invoice\BillKind;
|
2021-06-13 11:33:50 +02:00
|
|
|
use App\Member\Member;
|
2021-07-17 15:58:38 +02:00
|
|
|
use App\Nationality;
|
|
|
|
use App\Payment\Subscription;
|
2021-06-13 11:33:50 +02:00
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
|
2021-11-19 22:58:27 +01:00
|
|
|
/**
|
|
|
|
* @extends Factory<Member>
|
|
|
|
*/
|
2021-06-13 11:33:50 +02:00
|
|
|
class MemberFactory extends Factory
|
|
|
|
{
|
|
|
|
protected $model = Member::class;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Define the model's default state.
|
|
|
|
*
|
2021-11-19 22:58:27 +01:00
|
|
|
* @return array<string, mixed>
|
2021-06-13 11:33:50 +02:00
|
|
|
*/
|
|
|
|
public function definition()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'firstname' => $this->faker->firstName,
|
|
|
|
'lastname' => $this->faker->lastName,
|
|
|
|
'birthday' => $this->faker->dateTimeBetween('-30 years'),
|
|
|
|
'joined_at' => $this->faker->dateTimeBetween('-30 years'),
|
|
|
|
'send_newspaper' => $this->faker->boolean,
|
|
|
|
'address' => $this->faker->streetAddress,
|
2021-11-19 22:58:27 +01:00
|
|
|
'zip' => $this->faker->postcode,
|
2021-06-13 11:33:50 +02:00
|
|
|
'location' => $this->faker->city,
|
2023-02-05 23:35:08 +01:00
|
|
|
'email' => $this->faker->safeEmail(),
|
2023-11-24 13:28:54 +01:00
|
|
|
'recertified_at' => null,
|
2021-06-13 11:33:50 +02:00
|
|
|
];
|
|
|
|
}
|
2021-07-17 15:58:38 +02:00
|
|
|
|
|
|
|
public function defaults(): self
|
|
|
|
{
|
|
|
|
$country = Country::count()
|
|
|
|
? Country::get()->random()
|
|
|
|
: Country::factory()->create();
|
|
|
|
$group = Group::count()
|
|
|
|
? Group::get()->random()
|
|
|
|
: Group::factory()->create();
|
|
|
|
$nationality = Nationality::count()
|
|
|
|
? Nationality::get()->random()
|
|
|
|
: Nationality::factory()->create();
|
|
|
|
$subscription = Subscription::count()
|
|
|
|
? Subscription::get()->random()
|
|
|
|
: Subscription::factory()->for(Fee::factory())->create();
|
|
|
|
|
|
|
|
return $this
|
|
|
|
->for($country)
|
|
|
|
->for($group)
|
|
|
|
->for($nationality)
|
|
|
|
->for($subscription);
|
|
|
|
}
|
|
|
|
|
2022-11-07 16:18:11 +01:00
|
|
|
public function postBillKind(): self
|
|
|
|
{
|
|
|
|
return $this->state([
|
2022-12-06 23:11:57 +01:00
|
|
|
'bill_kind' => BillKind::POST,
|
2022-11-07 16:18:11 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function emailBillKind(): self
|
|
|
|
{
|
|
|
|
return $this->state([
|
2022-12-06 23:11:57 +01:00
|
|
|
'bill_kind' => BillKind::EMAIL,
|
2022-11-07 16:18:11 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2021-11-19 22:58:27 +01:00
|
|
|
public function inNami(int $namiId): self
|
|
|
|
{
|
|
|
|
return $this->state(['nami_id' => $namiId]);
|
|
|
|
}
|
|
|
|
|
2023-12-16 00:16:07 +01:00
|
|
|
public function sameFamilyAs(Member $member): self
|
|
|
|
{
|
|
|
|
return $this->state([
|
|
|
|
'firstname' => $member->firstname . 'a',
|
|
|
|
'lastname' => $member->lastname,
|
|
|
|
'address' => $member->address,
|
|
|
|
'zip' => $member->zip,
|
|
|
|
'location' => $member->location,
|
|
|
|
]);
|
|
|
|
}
|
2021-06-13 11:33:50 +02:00
|
|
|
}
|