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.
This commit is contained in:
fsociety
2024-10-02 12:49:27 +02:00
parent e937176d52
commit 75f11e3023

View File

@@ -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),
];
}