From 65fb920150330572e606f83f46cc5fe9197c4419 Mon Sep 17 00:00:00 2001 From: fsociety Date: Mon, 30 Sep 2024 15:22:33 +0200 Subject: [PATCH] feat: add payment tracking to user profiles - Added a check to update the 'paid' status of a user's paymentEvents if the current year's payment has been made - Updated the user profile view to display past payments - Added 'paymentEvents' to the query in EinundzwanzigPlebTable.php to fetch the current year's payments - Added a 'payment' column to the table in EinundzwanzigPlebTable.php to display the amount of the user's current year's payment --- app/Livewire/EinundzwanzigPlebTable.php | 9 +++ ...add_paid_field_to_payment_events_table.php | 28 ++++++++ resources/views/components/detail.blade.php | 70 +++++++++++++++---- .../views/pages/association/profile.blade.php | 4 ++ 4 files changed, 99 insertions(+), 12 deletions(-) create mode 100644 database/migrations/2024_09_30_131604_add_paid_field_to_payment_events_table.php diff --git a/app/Livewire/EinundzwanzigPlebTable.php b/app/Livewire/EinundzwanzigPlebTable.php index d36aaeb..32f705c 100644 --- a/app/Livewire/EinundzwanzigPlebTable.php +++ b/app/Livewire/EinundzwanzigPlebTable.php @@ -49,6 +49,7 @@ final class EinundzwanzigPlebTable extends PowerGridComponent return EinundzwanzigPleb::query() ->with([ 'profile', + 'paymentEvents' => fn($query) => $query->where('year', date('Y')), ]) ->where('association_status', '>', 1) ->orWhereNotNull('application_for'); @@ -74,6 +75,11 @@ final class EinundzwanzigPlebTable extends PowerGridComponent $model->application_for, )->label() . '' : '', ) + ->add( + 'payment', + fn(EinundzwanzigPleb $model) + => $model->paymentEvents->count() > 0 ? $model->paymentEvents->first()->amount : 'keine Zahlung vorhanden', + ) ->add( 'npub', fn(EinundzwanzigPleb $model) @@ -112,6 +118,9 @@ final class EinundzwanzigPlebTable extends PowerGridComponent ->visibleInExport( visible: true) ->sortable(), + Column::make('Beitrag ' . date('Y'), 'payment') + ->visibleInExport( visible: true), + Column::make('Bewirbt sich für', 'for', 'application_for') ->visibleInExport( visible: false) ->sortable(), diff --git a/database/migrations/2024_09_30_131604_add_paid_field_to_payment_events_table.php b/database/migrations/2024_09_30_131604_add_paid_field_to_payment_events_table.php new file mode 100644 index 0000000..bdf03dd --- /dev/null +++ b/database/migrations/2024_09_30_131604_add_paid_field_to_payment_events_table.php @@ -0,0 +1,28 @@ +boolean('paid')->default(false); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('payment_events', function (Blueprint $table) { + // + }); + } +}; diff --git a/resources/views/components/detail.blade.php b/resources/views/components/detail.blade.php index a5fe684..7ce67e9 100644 --- a/resources/views/components/detail.blade.php +++ b/resources/views/components/detail.blade.php @@ -1,14 +1,60 @@ -
- @if($row->application_text ) -
-
- - - -
{{ $row->application_text }}
+
+ +
+ @if($row->application_text ) +
+
+ + + +
{{ $row->application_text }}
+
-
- @else - keine Bewerbung vorhanden - @endif + @else + keine Bewerbung vorhanden + @endif +
+ +
+

+ bisherige Zahlungen

+ + + + + + + + + + + + + @foreach($row->paymentEvents as $payment) + + + + + + @endforeach + +
+
Satoshis
+
+
{{ $payment->amount }}
+
+
{{ $payment->year }}
+
+
{{ $payment->event_id }}
+
+
+
diff --git a/resources/views/pages/association/profile.blade.php b/resources/views/pages/association/profile.blade.php index 9aa248e..e645008 100644 --- a/resources/views/pages/association/profile.blade.php +++ b/resources/views/pages/association/profile.blade.php @@ -126,6 +126,10 @@ $searchPaymentEvent = function () { fn($yearPaid) => $yearPaid['year'] == date('Y') && $yearPaid['amount'] == $this->amountToPay, ); + if ($this->currentYearIsPaid) { + $this->currentPleb->paymentEvents->first()->update(['paid' => true]); + } + $this->paid = true; } };