From 75f11e3023b068c8d0d46697f929831dffe55c1e Mon Sep 17 00:00:00 2001 From: fsociety Date: Wed, 2 Oct 2024 12:49:27 +0200 Subject: [PATCH] feat: add payment status filter in EinundzwanzigPlebTable query This commit modifies the query in EinundzwanzigPlebTable.php to filter out the paymentEvents where 'paid' is false. It also includes minor refactoring and formatting changes to improve code readability. --- app/Livewire/EinundzwanzigPlebTable.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/Livewire/EinundzwanzigPlebTable.php b/app/Livewire/EinundzwanzigPlebTable.php index dd688cc..9d72598 100644 --- a/app/Livewire/EinundzwanzigPlebTable.php +++ b/app/Livewire/EinundzwanzigPlebTable.php @@ -49,7 +49,10 @@ final class EinundzwanzigPlebTable extends PowerGridComponent return EinundzwanzigPleb::query() ->with([ 'profile', - 'paymentEvents' => fn($query) => $query->where('year', date('Y')), + 'paymentEvents' => fn($query) + => $query + ->where('year', date('Y')) + ->where('paid', true), ]) ->where('association_status', '>', 1) ->orWhereNotNull('application_for'); @@ -78,7 +81,8 @@ final class EinundzwanzigPlebTable extends PowerGridComponent ->add( 'payment', fn(EinundzwanzigPleb $model) - => $model->paymentEvents->count() > 0 && $model->paymentEvents->first()->paid ? $model->paymentEvents->first()->amount : 'keine Zahlung vorhanden', + => $model->paymentEvents->count() > 0 && $model->paymentEvents->first( + )->paid ? $model->paymentEvents->first()->amount : 'keine Zahlung vorhanden', ) ->add( 'npub', @@ -105,7 +109,7 @@ final class EinundzwanzigPlebTable extends PowerGridComponent { return [ Column::make('Avatar', 'avatar') - ->visibleInExport( visible: false), + ->visibleInExport(visible: false), Column::make('Npub', 'npub') ->visibleInExport(visible: false) @@ -115,18 +119,18 @@ final class EinundzwanzigPlebTable extends PowerGridComponent ->sortable(), Column::make('Aktueller Status', 'association_status_formatted', 'association_status') - ->visibleInExport( visible: true) + ->visibleInExport(visible: true) ->sortable(), Column::make('Beitrag ' . date('Y'), 'payment') - ->visibleInExport( visible: true), + ->visibleInExport(visible: true), Column::make('Bewirbt sich für', 'for', 'application_for') - ->visibleInExport( visible: false) + ->visibleInExport(visible: false) ->sortable(), Column::action('Action') - ->visibleInExport( visible: false), + ->visibleInExport(visible: false), ]; }