2021-07-15 21:14:25 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Database\Factories\Payment;
|
|
|
|
|
|
|
|
use App\Fee;
|
|
|
|
use App\Payment\Payment;
|
|
|
|
use App\Payment\Status;
|
|
|
|
use App\Payment\Subscription;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
2022-12-13 23:11:32 +01:00
|
|
|
use Tests\RequestFactories\Child;
|
2021-07-15 21:14:25 +02:00
|
|
|
|
2023-02-17 18:57:11 +01:00
|
|
|
/**
|
|
|
|
* @extends Factory<Payment>
|
|
|
|
*/
|
2021-07-15 21:14:25 +02:00
|
|
|
class PaymentFactory extends Factory
|
|
|
|
{
|
|
|
|
protected $model = Payment::class;
|
|
|
|
|
|
|
|
public function definition(): array
|
|
|
|
{
|
|
|
|
return [
|
2022-02-12 14:41:46 +01:00
|
|
|
'nr' => $this->faker->year,
|
|
|
|
'subscription_id' => Subscription::factory()->create()->id,
|
|
|
|
'status_id' => Status::factory()->create()->id,
|
|
|
|
'last_remembered_at' => $this->faker->dateTime,
|
2021-07-15 21:14:25 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function notPaid(): self
|
|
|
|
{
|
|
|
|
return $this->for(Status::whereName('Nicht bezahlt')->first());
|
|
|
|
}
|
|
|
|
|
2021-07-17 16:57:37 +02:00
|
|
|
public function paid(): self
|
|
|
|
{
|
|
|
|
return $this->for(Status::whereName('Rechnung beglichen')->first());
|
|
|
|
}
|
|
|
|
|
2021-07-15 21:14:25 +02:00
|
|
|
public function nr(string $nr): self
|
|
|
|
{
|
|
|
|
return $this->state(['nr' => $nr]);
|
|
|
|
}
|
|
|
|
|
2022-12-13 23:11:32 +01:00
|
|
|
/**
|
2022-12-14 00:23:03 +01:00
|
|
|
* @param array<int, Child> $children
|
|
|
|
* @param array<string, mixed> $state
|
2022-12-13 23:11:32 +01:00
|
|
|
*/
|
2022-12-14 00:23:03 +01:00
|
|
|
public function subscription(string $name, array $children, array $state = []): self
|
2021-07-15 21:14:25 +02:00
|
|
|
{
|
|
|
|
return $this->for(
|
2022-12-14 00:23:03 +01:00
|
|
|
Subscription::factory()->state(['name' => $name])->for(Fee::factory())->children($children)->state($state)
|
2021-07-15 21:14:25 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|