2022-03-20 16:33:56 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Database\Factories\Member;
|
|
|
|
|
2022-11-16 23:39:44 +01:00
|
|
|
use App\Activity;
|
2022-03-20 16:33:56 +01:00
|
|
|
use App\Group;
|
|
|
|
use App\Member\Membership;
|
2022-11-16 23:39:44 +01:00
|
|
|
use App\Subactivity;
|
2022-12-11 21:00:48 +01:00
|
|
|
use Carbon\Carbon;
|
2022-03-20 16:33:56 +01:00
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @extends Factory<Membership>
|
|
|
|
*/
|
|
|
|
class MembershipFactory extends Factory
|
|
|
|
{
|
|
|
|
public $model = Membership::class;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Define the model's default state.
|
|
|
|
*
|
|
|
|
* @return array<string, mixed>
|
|
|
|
*/
|
|
|
|
public function definition()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'group_id' => Group::factory()->createOne()->id,
|
|
|
|
'from' => now()->subMonths(3),
|
2022-12-11 21:00:48 +01:00
|
|
|
'promised_at' => null,
|
2022-03-20 16:33:56 +01:00
|
|
|
];
|
|
|
|
}
|
2022-10-30 16:10:21 +01:00
|
|
|
|
|
|
|
public function inNami(int $namiId): self
|
|
|
|
{
|
|
|
|
return $this->state(['nami_id' => $namiId]);
|
|
|
|
}
|
2022-11-16 23:39:44 +01:00
|
|
|
|
2023-02-06 00:57:37 +01:00
|
|
|
public function local(): self
|
|
|
|
{
|
|
|
|
return $this->state(['nami_id' => null]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function inLocal(string $activity, ?string $subactivity = null): self
|
|
|
|
{
|
|
|
|
$instance = $this->for(Activity::factory()->name($activity));
|
|
|
|
|
|
|
|
if ($subactivity) {
|
|
|
|
$instance = $instance->for(Subactivity::factory()->name($subactivity));
|
|
|
|
}
|
|
|
|
|
|
|
|
return $instance;
|
|
|
|
}
|
|
|
|
|
2023-02-23 01:20:51 +01:00
|
|
|
public function ended(): self
|
|
|
|
{
|
|
|
|
return $this->state(['to' => now()->subDays(2)]);
|
|
|
|
}
|
|
|
|
|
2022-11-16 23:39:44 +01:00
|
|
|
public function in(string $activity, int $activityNamiId, ?string $subactivity = null, ?int $subactivityNamiId = null): self
|
|
|
|
{
|
|
|
|
$instance = $this->for(Activity::factory()->name($activity)->inNami($activityNamiId));
|
|
|
|
|
|
|
|
if ($subactivity) {
|
|
|
|
$instance = $instance->for(Subactivity::factory()->name($subactivity)->inNami($subactivityNamiId));
|
|
|
|
}
|
|
|
|
|
|
|
|
return $instance;
|
|
|
|
}
|
2022-12-11 21:00:48 +01:00
|
|
|
|
|
|
|
public function promise(Carbon $value): self
|
|
|
|
{
|
|
|
|
return $this->state([
|
|
|
|
'promised_at' => $value->format('Y-m-d'),
|
|
|
|
]);
|
|
|
|
}
|
2022-03-20 16:33:56 +01:00
|
|
|
}
|