diff --git a/app/Payment/Subscription.php b/app/Payment/Subscription.php index bd2d70c6..abe7cf21 100644 --- a/app/Payment/Subscription.php +++ b/app/Payment/Subscription.php @@ -15,15 +15,7 @@ class Subscription extends Model /** * @var array */ - public $fillable = ['name', 'fee_id', 'split', 'for_promise']; - - /** - * @var array - */ - public $casts = [ - 'split' => 'boolean', - 'for_promise' => 'boolean', - ]; + public $fillable = ['name', 'fee_id']; public function getAmount(): int { diff --git a/app/Payment/SubscriptionController.php b/app/Payment/SubscriptionController.php index 6bd184db..153c9d3b 100644 --- a/app/Payment/SubscriptionController.php +++ b/app/Payment/SubscriptionController.php @@ -39,12 +39,9 @@ class SubscriptionController extends Controller { $subscriptionParams = $request->validate([ 'name' => 'required|max:255', - 'split' => 'present|boolean', 'fee_id' => 'required|exists:fees,id', - 'for_promise' => 'present|boolean', ], [], [ 'fee_id' => 'Nami-Beitrag', - 'for_promise' => 'Für Versprechen benutzen', ]); $children = $request->validate([ @@ -76,12 +73,9 @@ class SubscriptionController extends Controller { $subscriptionParams = $request->validate([ 'name' => 'required|max:255', - 'split' => 'present|boolean', 'fee_id' => 'required|exists:fees,id', - 'for_promise' => 'present|boolean', ], [], [ 'fee_id' => 'Nami-Beitrag', - 'for_promise' => 'Für Versprechen benutzen', ]); $subscription->update($subscriptionParams); $children = $request->validate([ diff --git a/app/Payment/SubscriptionResource.php b/app/Payment/SubscriptionResource.php index 78f1132b..e1234b32 100644 --- a/app/Payment/SubscriptionResource.php +++ b/app/Payment/SubscriptionResource.php @@ -26,11 +26,9 @@ class SubscriptionResource extends JsonResource 'name' => $this->name, 'fee_id' => $this->fee_id, 'fee_name' => $this->fee->name, - 'amount_human' => number_format($this->getAmount() / 100, 2, ',', '.').' €', + 'amount_human' => number_format($this->getAmount() / 100, 2, ',', '.') . ' €', 'amount' => $this->getAmount(), - 'split' => $this->split, 'children' => SubscriptionChildResource::collection($this->whenLoaded('children')), - 'for_promise' => $this->for_promise, ]; } diff --git a/database/factories/Payment/SubscriptionFactory.php b/database/factories/Payment/SubscriptionFactory.php index cd7c21e3..6195feed 100644 --- a/database/factories/Payment/SubscriptionFactory.php +++ b/database/factories/Payment/SubscriptionFactory.php @@ -20,7 +20,6 @@ class SubscriptionFactory extends Factory return [ 'name' => $this->faker->word, 'fee_id' => Fee::factory()->createOne()->id, - 'for_promise' => false, ]; } @@ -42,9 +41,4 @@ class SubscriptionFactory extends Factory return $instance; } - - public function forPromise(): self - { - return $this->state(['for_promise' => true]); - } } diff --git a/database/migrations/2023_12_12_015320_create_invoices_table.php b/database/migrations/2023_12_12_015320_create_invoices_table.php index 67bffca6..18ef224f 100644 --- a/database/migrations/2023_12_12_015320_create_invoices_table.php +++ b/database/migrations/2023_12_12_015320_create_invoices_table.php @@ -92,6 +92,11 @@ return new class extends Migration } Schema::dropIfExists('payments'); + + Schema::table('subscriptions', function (Blueprint $table) { + $table->dropColumn('split'); + $table->dropColumn('for_promise'); + }); } /** @@ -101,7 +106,17 @@ return new class extends Migration */ public function down() { + Schema::table('subscriptions', function (Blueprint $table) { + $table->boolean('split')->default(false); + $table->boolean('for_promise')->default(false); + }); Schema::dropIfExists('invoice_positions'); Schema::dropIfExists('invoices'); + Schema::create('payments', function ($table) { + $table->id(); + $table->string('nr'); + $table->integer('subscription_id'); + $table->json('invoice_data'); + }); } }; diff --git a/resources/js/views/subscription/SubscriptionForm.vue b/resources/js/views/subscription/SubscriptionForm.vue index 04555d0b..f7fa2cce 100644 --- a/resources/js/views/subscription/SubscriptionForm.vue +++ b/resources/js/views/subscription/SubscriptionForm.vue @@ -10,21 +10,23 @@
- - - +
- + Position hinzufügen @@ -36,11 +38,6 @@