From 7eeb88ce98ae8354aa951b2f309dd3d59e6d0a23 Mon Sep 17 00:00:00 2001
From: philipp lang <philipp@aweos.de>
Date: Thu, 15 Jul 2021 21:14:25 +0200
Subject: [PATCH] Add PaymentFactory and SubscriptionFactory

---
 database/factories/Payment/PaymentFactory.php | 40 +++++++++++++++++++
 .../factories/Payment/SubscriptionFactory.php | 21 ++++++++++
 2 files changed, 61 insertions(+)
 create mode 100644 database/factories/Payment/PaymentFactory.php
 create mode 100644 database/factories/Payment/SubscriptionFactory.php

diff --git a/database/factories/Payment/PaymentFactory.php b/database/factories/Payment/PaymentFactory.php
new file mode 100644
index 00000000..81fb280e
--- /dev/null
+++ b/database/factories/Payment/PaymentFactory.php
@@ -0,0 +1,40 @@
+<?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 [
+            //
+        ];
+    }
+
+    public function notPaid(): self
+    {
+        return $this->for(Status::whereName('Nicht bezahlt')->first());
+    }
+
+    public function nr(string $nr): self
+    {
+        return $this->state(['nr' => $nr]);
+    }
+
+    public function subscription(string $name, int $amount): self
+    {
+        return $this->for(
+            Subscription::factory()->state(['name' => $name, 'amount' => $amount])->for(Fee::first()),
+        );
+    }
+
+}
diff --git a/database/factories/Payment/SubscriptionFactory.php b/database/factories/Payment/SubscriptionFactory.php
new file mode 100644
index 00000000..1297fc5a
--- /dev/null
+++ b/database/factories/Payment/SubscriptionFactory.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace Database\Factories\Payment;
+
+use App\Payment\Subscription;
+use Illuminate\Database\Eloquent\Factories\Factory;
+
+class SubscriptionFactory extends Factory
+{
+
+    protected $model = Subscription::class;
+
+    public function definition(): array
+    {
+        return [
+            'name' => $this->faker->name,
+            'amount' => $this->faker->numberBetween(1000, 50000),
+        ];
+    }
+
+}