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;
|
|
|
|
|
|
|
|
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]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function subscription(string $name, int $amount): self
|
|
|
|
{
|
|
|
|
return $this->for(
|
2022-11-18 22:34:50 +01:00
|
|
|
Subscription::factory()->state(['name' => $name, 'amount' => $amount])->for(Fee::factory())
|
2021-07-15 21:14:25 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|